LINUX CLASSES - FILES
How do I Delete Files and Directories?
Deleting FilesReady to do a little damage? The rm command removes a file (assuming you have permission to do so) without even saying hasta la vista. Be sure you really want to delete your files before you use rm, because once the files are gone, they're not coming back. For example,
immediately deletes the file named wallet in the current directory without prompting. If you want to be prompted before the deletion, use the -i flag.
Note: There is one little safety feature in rm--it won't delete a directory (unless you use the -r flag).
One other rm flag is -f, which translates roughly to "Don't ask me any questions--just delete the files." While rm normally asks for confirmation before deleting a write-protected file, the -f (force) flag overrides this prompt.
Be careful with the rm command, since the multiuser nature of Linux does not allow for undelete as in DOS. As soon as you let go of the space occupied by a file, the operating system is likely to use it for something else.
Deleting Directories
If you created a directory named spelunking six months ago, and now you're not so keen on crawling through slimy caves, the rmdir command may be able to help:
$ rmdir spelunking
This command removes the specified directory, but only if it's empty. If the directory contains files or subdirectories, you'll have to delete them using rm first.
One alternative to painstakingly removing all the contents of a directory that you just want to make disappear is to use the rm -r command. The -r flag gives rm license to kill directories, their files, and even their subdirectories. Be very sure you understand what's about to happen before using a command like this:
$ rm -r spelunking
Let's just say that careless use of the -r flag might end your spelunking hobby prematurely.
Previous Lesson: Creating Files and Directories
Next Lesson: Linux Files - Wildcards
Go there...
http://lowfatlinux.com/linux-delete-files-rm.html
Don
No comments:
Post a Comment