View unanswered posts    View active topics

All times are UTC - 6 hours





Post new topic Reply to topic  [ 10 posts ] 
Print view Previous topic   Next topic  
Author Message
Search for:
PostPosted: Mon Nov 27, 2006 6:10 pm 
Offline
Joined: Tue Jun 27, 2006 5:19 pm
Posts: 100
Location: Naptown, Indiana; USA
Each time I attempt to recursively delete a non-empty directory, I am asked to dive into the directory and delete each file. There must be an easier way.

Question: Is the following command inappropriate for deleting a non-empty directory?

Code:
 rm -r directory

_________________
R5.5; PVR-250; FX5200; Dell 4300 with Intel Pentium 4 (1.5 GHz);
BIOS Revision A02; 512MB RAM; 500GB PATA HDD


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 27, 2006 7:12 pm 
Offline
Joined: Tue Apr 13, 2004 6:51 pm
Posts: 890
Location: Groton, MA
sure it is.

also
Code:
rm -rf
may be useful. the -f is 'force' which disables all prompts and just does the rm (where permissions allow)

_________________
R5F1 - Dell P4 2.4Ghz 500MB - PVR250 x 2 - GeForce FX 5200 - Onboard sound/NIC 80GB ATA/250GB ATA/400GB SATA


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 27, 2006 8:44 pm 
Offline
Joined: Sun Jun 12, 2005 10:55 pm
Posts: 3161
Location: Warwick, RI
Hi,

I use the rm -rf frequently myself, HOWEVER, do be careful as it does what you tell it. There are NO questions like "are you sure, really sure?" and then put it a recycle bin.

Mike


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 28, 2006 4:44 pm 
Offline
Joined: Tue Jun 27, 2006 5:19 pm
Posts: 100
Location: Naptown, Indiana; USA
mjl wrote:
Hi,

I use the rm -rf frequently myself, HOWEVER, do be careful as it does what you tell it. There are NO questions like "are you sure, really sure?" and then put it a recycle bin.

Mike


Understood. It is a powerful command; not one to be taken lightly. However, if I need to delete a folder with hundreds of files, it seems the only way.

_________________
R5.5; PVR-250; FX5200; Dell 4300 with Intel Pentium 4 (1.5 GHz);
BIOS Revision A02; 512MB RAM; 500GB PATA HDD


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 01, 2006 5:28 pm 
Offline
Joined: Sat Apr 08, 2006 2:13 am
Posts: 40
You could always

Code:
rm /dir/* -i;rmdir /dir


Or leave out the -i if you don't want to be prompted for confirming deletion of each file.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 05, 2006 1:49 pm 
Offline
Joined: Tue Nov 14, 2006 2:55 pm
Posts: 245
Location: South Jersey
Linux quite annoyingly aliases "rm" to "rm -i" so it prompts you for confirmation. I usually remove the alias.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 05, 2006 7:25 pm 
Offline
Joined: Fri Sep 19, 2003 7:05 pm
Posts: 5088
Location: Fontana, Ca
You could also change it to "rm -fr". :)

_________________
cesman

When the source is open, the possibilities are endless!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 05, 2006 7:41 pm 
Offline
Joined: Sun Jun 12, 2005 10:55 pm
Posts: 3161
Location: Warwick, RI
Hi cesman,

Does the order of the switches actually play a part in the rm command? Also is there limit to the number of files in a directory that can be removed in this manner?

Reason for the question is when using motion, I had to use a special script as the quanity of files reached a certain level. tjc was very kind and provided that script for us (in the motion thread) which would empty the directory and not remove it.

Thanks
Mike


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 05, 2006 7:50 pm 
Offline
Joined: Fri Sep 19, 2003 7:05 pm
Posts: 5088
Location: Fontana, Ca
Hello mjl,

I don't know if the order matters. Yes, there is a limit, however I don't know what that is...

_________________
cesman

When the source is open, the possibilities are endless!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 05, 2006 8:05 pm 
Offline
Joined: Sun Jun 12, 2005 10:55 pm
Posts: 3161
Location: Warwick, RI
Hi,

Thank you cesman.

I think that ihatetivo may want to search for tjc's motion clean up script as it sounds like that may serve his needs better than the rm command.

It takes a couple of minutes for the script to clean out my motion folder each day however never fails to do exactly that task. A good test is to input tv into motion and let it run for a while. You can gather a lot of files rather quickly to play with :) Takes forever if you wait for the paperboy.

Mike


Top
 Profile  
 

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 


All times are UTC - 6 hours




Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group

Theme Created By ceyhansuyu