LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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.

Notices

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

Rep: Reputation: 30
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
 
Old 08-22-2005, 07:03 AM   #2
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 56
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/{} \;
 
  


Reply


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


All times are GMT -5. The time now is 03:35 PM.

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