remove all directories and sub-directories | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Go Back    


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 !!

remove all directories and sub-directories

UNIX for Dummies Questions & Answers


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 08-21-2008
venhart venhart is offline
Banned
 
Join Date: Jul 2008
Last Activity: 10 October 2011, 8:41 AM EDT
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
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
Sponsored Links
    #2  
Old 08-21-2008
saravanan.mr saravanan.mr is offline
Registered User
 
Join Date: Aug 2008
Last Activity: 7 October 2009, 1:11 AM EDT
Location: india
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
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
Sponsored Links
    #3  
Old 08-21-2008
priyam priyam is offline
Registered User
 
Join Date: Jul 2008
Last Activity: 29 September 2009, 5:03 AM EDT
Location: India
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Try this ...

You can also do


rm -r <directory_name>
    #4  
Old 08-22-2008
sydney2008 sydney2008 is offline
Registered User
 
Join Date: Aug 2008
Last Activity: 2 April 2009, 5:04 PM EDT
Location: Sydney, Australia
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
You can also try

rm -rf directoryname

ex : rm -rf /home/jeff/sydney

This will remove all directories and sub directories recursively.
Sponsored Links
    #5  
Old 08-25-2008
etcpasswd's Avatar
etcpasswd etcpasswd is offline
Registered User
 
Join Date: Aug 2008
Last Activity: 4 June 2010, 11:53 AM EDT
Posts: 44
Thanks: 0
Thanked 0 Times in 0 Posts
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.
Sponsored Links
    #6  
Old 08-25-2008
agasamapetilon agasamapetilon is offline
Registered User
 
Join Date: Aug 2008
Last Activity: 20 May 2010, 10:52 AM EDT
Posts: 68
Thanks: 0
Thanked 0 Times in 0 Posts
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

Sponsored Links
    #7  
Old 08-25-2008
wempy's Avatar
wempy wempy is offline
Registered User
 
Join Date: Jun 2006
Last Activity: 18 July 2013, 6:39 AM EDT
Location: Harpenden, UK
Posts: 219
Thanks: 0
Thanked 3 Times in 3 Posts
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

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Using grep command to find the pattern of text in all directories and sub-directories. vinothrajan55 UNIX for Dummies Questions & Answers 1 11-11-2011 02:20 AM
List directories and sub directories recursively excluding files pointers UNIX for Dummies Questions & Answers 3 02-23-2011 08:39 PM
How to list all the directories, sub directories in a mount along with size in ascending order? nmakkena Shell Programming and Scripting 4 10-27-2010 02:56 AM
Script for parsing directories one level and finding directories older than n days ejianu Shell Programming and Scripting 5 08-26-2009 11:24 AM
check if multiple directories exist else create missing directories ramky79 Shell Programming and Scripting 7 08-19-2009 02:23 PM



All times are GMT -4. The time now is 09:10 AM.