Monday, October 30, 2006

Remove a File or Directory Recursively

# rm filename (removes a single file)
# rm filename? (matches single character. e.g. filename1, filename2, 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 directoryname recursively and all its contents without prompting (-f) read only files/directories)
# rm -Rf /home/esofthub/directoryname (the -R deletes directoryname 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)

No comments: