The manual Page
Version française
   
index | glossary | news | downloads | links ]
  Unix
Unix rights
manual pages
Unix commands
how to use vi
cron
rm
 
news
glossary
links
downloads
 
credits
contact
 
 
search
 
last update
19/02/2003
Valid HTML 4.0!
Valid CSS!
Hit-Parade
Mesurez votre audience


  rm

Description

The rm (remove) is bsically used to delete a file, a link or a directory.

WARNING! Any deleted file cannot be recovered.

Use

Synopsis

rm [options] file1 file2...

rm is simply folowed by one or several options (not mandatory) and the followed by the name(s) of the file(s) to be deleted. It is also possible to specify the name of a directory (-d or -r options). It is also possible to use special tokens (*) in the file name (rm *.class, rm foo*).

Options

rm may be used with options. Here is the list:

option effect
-d, --directory this option is used to delete a directory hard link. In practice, it is rarely used because the function ln does not allow the creation of hard links on directories.
-f, --force Every specified file is removed without asking for confirmation (even read only files). Files that do not exist are ignored. This option is pretty dangerous, espexially with -r, so be careful...
-i, --interactive interactive mode. Confirmation is granted for every file. Opposed to -f.
-r, -R, --recursive recursive mode. rm will remove the contents of the given directory recursively, i.e. files and subdirectories. rm will also remove the given directory. It is a very dangerous option when used with -f.
-v, --verbose verbose mode. rm will display on the standard output what it is doing.
--help displays a help screen
--version displays the current version of rm and quit

These options may be conbimed.

Examples

rm foo.txt deletes the file called foo.txt located in the current directory
rm -f foo/bar.c deletes the file called foo/bar.c (relative path) without asking for confirmation (option -f, see below)
rm -r /home/my_home/rep1 deletes the directory /home/my_home/rep2 and its content (even hidden files but asks for confirmation
rm -rf /home/my_home/rep2 deletes the directory /home/my_home/rep2 and its content (even hidden files) without asking for confirmation
rm -rf /home/my_home/rep3/* deletes the content of the directory /home/my_home/rep3 (except hidden files) without asking for confirmation. /home/my_home/rep2 is not deleted.

Remarks

1. By default, rm asks for confirmation before removing a file (option -i). However, for normal Unix users, the rm command is often redefined with the -f option. It is then adviced to use the -i option as much as possible.

2. It also highly adviced to think (a lot!) before using 'rm -rf': everything is deleted without the possibilty to recove them in case of mistake...

3. By default, rn does not remove directories. To remove an empty directory, it is better to use the rmdir dir command rather than using a 'rm -r rep'. See also the tricks below.

Tricks

To remove directly a non empty directory, use (be beware of the -f option!):

rm -rf directory

Note to handle hidden files: hidden files are deleted only when they explicitly named (rm .file, rm .*). The only case when hidden files are deleted is when we ask rm to delete a complete directory with the -r option (rm -r directory).

References

printable format printable format



Copyright © 2000-2002 themanualpage.org - This site is submissive to the terms of the GNU GPL and FDL licences.