LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Empty directory contents (https://www.linuxquestions.org/questions/linux-general-1/empty-directory-contents-355649/)

stefaandk 08-21-2005 09:06 PM

Empty directory contents
 
Hi,

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.

Cheers

homey 08-22-2005 07:03 AM

Hi,
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 {} \;

or
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/{} \;


All times are GMT -5. The time now is 10:46 PM.