Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 08-21-2005, 09:06 PM   #1
Registered: Jun 2005
Distribution: Centos
Posts: 215

Rep: Reputation: 30
Empty directory contents


I'm trying to ge the syntax right to remove files in a subdir with multiple subdirs, I don't want to delete the actual dirs, just the contents.

Old 08-22-2005, 07:03 AM   #2
Senior Member
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 59
Here are a couple of examples. The first one gets rid of all files and next, you could just get rid of a certain type of file....

cd /home/tech
find . -type f -exec rm {} \;

cd /home/tech
find . -type f -name '*.jpg' -exec rm {} \;

You could also copy the directory structure to a new sub directory and take it from there....

cd /home/tech
find . -type d -exec mkdir -p /home/new/{} \;


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
rm: cannot remove directory `ff': Directory not empty blancs Linux - General 17 08-29-2011 01:47 PM
cannot list directory contents kpachopoulos Linux - General 2 11-29-2005 05:24 PM
How can I copy a directory and it's contents with CLI? CyberLord_7 Linux - General 2 03-30-2004 11:35 AM
mv the contents of one directory to the parent directory warkrime Linux - Newbie 4 07-14-2003 07:03 PM
Get directory contents vank Programming 6 10-19-2002 10:13 AM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:22 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration