The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Remove directories kamathg Shell Programming and Scripting 2 06-25-2007 04:16 PM
moving directories to new directories on multiple servers mackdaddy07 Shell Programming and Scripting 0 04-06-2007 11:30 AM
Need to remove files older than 30 days except directories malaymaru Shell Programming and Scripting 6 11-13-2006 11:50 PM
How to Remove Ctrl M characters in files from directories and its subdirectories skdp Shell Programming and Scripting 7 07-29-2006 11:53 PM
Check all files in directories for string and remove.. possible? LordJezo Shell Programming and Scripting 7 11-30-2005 01:00 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-21-2008
venhart venhart is offline
Registered User
  
 

Join Date: Jul 2008
Posts: 39
remove all directories and sub-directories

Please could someone advise me the unix command to remove all directories and sub-directories with files within the directory structures.

Thank you
  #2 (permalink)  
Old 08-21-2008
saravanan.mr saravanan.mr is offline
Registered User
  
 

Join Date: Aug 2008
Location: india
Posts: 1
first get the path of the directory u need to delete...

for ex:
consider 'tmp' is the directory to b deleted
/home/user85/tmp

then from your home directory..,,, use

rm -ir /home/user85/tmp/ --- for deleting interactively
  #3 (permalink)  
Old 08-21-2008
priyam priyam is offline
Registered User
  
 

Join Date: Jul 2008
Location: India
Posts: 24
Try this ...

You can also do


rm -r <directory_name>
  #4 (permalink)  
Old 08-22-2008
sydney2008 sydney2008 is offline
Registered User
  
 

Join Date: Aug 2008
Location: Sydney, Australia
Posts: 26
You can also try

rm -rf directoryname

ex : rm -rf /home/jeff/sydney

This will remove all directories and sub directories recursively.
  #5 (permalink)  
Old 08-25-2008
etcpasswd's Avatar
etcpasswd etcpasswd is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 40
venhart

I recommend sydney2008 way of deleting directories that are not empty.
But if you want an interactive way of deletion you may use saravanan.mr.

although deleting interactively if the safest way to do because it will prompt you a confirmation before doing a deletion.
  #6 (permalink)  
Old 08-25-2008
agasamapetilon agasamapetilon is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 67
To delete one or more files or directories recursively and forcing deletion of write-protected files:
Code:
rm -Rf /your/directory
If you're not so sure what arguments to use, take a look at the man pages for the command:
Code:
man rm
  #7 (permalink)  
Old 08-25-2008
wempy's Avatar
wempy wempy is offline
Registered User
  
 

Join Date: Jun 2006
Location: Harpenden, UK
Posts: 205
And as a side-note, if you are on a Red-Hat based system, or any system that aliases rm to rm -i then to not expand the alias prepend a backslash in front of the command i.e.

\rm -r dir-to-delete
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 10:37 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0