Skip to content
Blog HOWTO Remove a File or Directory Recursively

HOWTO Remove a File or Directory Recursively

# rm filename (removes a single file)
# rm 
filename? (matches single character. e.g. filename1filename2,filename3)
# rm 
filename[1-5] (matches filename1 thru filename5)
# rm 
filename* (removes everything that matches filename. e.g.filename122, filename222, filename.backup)

# rm -rf /home/esofthub/directoryname (the -r deletes directorynamerecursively and all its contents without prompting (-f) read only files/directories)
# rm -Rf /home/esofthub/
directoryname (the -R deletesdirectoryname recursively and all its contents without prompting (-f) read only files/directories)

# pwd
Note: Make darn sure you’re in the right directory!! For example, you might be inadvertently deleting the contents of /etc instead of user defined etc, such as, /tmp/etc/ or /raid/etc or /home/esoft/etc.
# rm * ((wildcard *) removes everything within a directory

# rmdir /home/esofthub/directoryname (deletes empty directories)


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.