rm - remove files or directories


Usage

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]%

-f

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]%

-r

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]%

CAUTION!

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.


Daniel J. Hood
Last modified: Thu Sep 30 12:52:42 EDT 2004