rm - remove files or directories
rm removes each specified file. By default, it does not remove directories.
linux3[103]% ls foobar sample.txt linux3[104]% rm sample.txt rm: remove `sample.txt'? y linux3[105]% ls foobar linux3[106]% |
Forces the removal of files, never prompting user
linux3[108]% ls foobar sample.txt linux3[109]% rm -f sample.txt linux3[110]% ls foobar linux3[111]% |
Removes the contents of directories recursively
linux3[131]% ls myDir linux3[132]% ls myDir bar.txt foo.txt linux3[133]% rm -r myDir rm: descend into directory `myDir'? y rm: remove `myDir/bar.txt'? y rm: remove `myDir/foo.txt'? y rm: remove directory `myDir'? y linux3[134]% ls linux3[135]% |
One should be careful when using rm -rf as this will blow away entire directory trees without asking the user. Not that it is a bad thing to do, but if you find yourself typing this, be sure to double check and make sure that what directories and files you are deleting are correct.