pavement

Rm

From FreeBSDwiki
(Difference between revisions)
Jump to: navigation, search
(Speak a little bit more abour -P)
(polishing)
Line 1: Line 1:
short for '''remove'''. Seriously, be careful when using this. There is no undelete once you've unlinked a file (unless you've aliased [[rm]] to a [[mv]] script that moves files to a trash folder or something -- not recommended because you will eventually find yourself on a system that doesn't have that alias and make a mistake.
+
Short for '''remove'''. Seriously, be careful when using this. There is no undelete once you've unlinked a file (unless you've aliased [[rm]] to a [[mv]] script that moves files to a trash folder or something -- which is not recommended because you will eventually find yourself on a system that doesn't have that alias and make a mistake.)
  
 
==Common flags==
 
==Common flags==
Line 12: Line 12:
 
==About the -P argument==
 
==About the -P argument==
  
Use this argument with extreme care : if you yant to remove a file that have hard links, the file '''will be''' overwritten and its contents will be lost, thus not accessible via the links. Example :
+
Use this argument with extreme care!  If you use '''rm -P''' to remove a file that has hard links, the file will be immediately overwritten and its contents will be lost, thus not accessible via the links. For example :
  $ echo 'Hello World' > foo
+
 
  $ ln foo bar
+
  $ '''echo 'Hello World' > foo'''
  $ cat foo bar
+
  $ '''ln -h foo bar'''
 +
  $ '''cat foo bar'''
 
  Hello World
 
  Hello World
 
  Hello World
 
  Hello World
  $ rm -P foo
+
  $ '''rm -P foo'''
  $ cat bar
+
  $ '''cat bar'''
  $ Hey !! where is bar contents ??
+
  $ '''Hey !! where is bar contents ??'''
 
  Hey, command not found
 
  Hey, command not found
  
 
See also [[rmdir]]
 
See also [[rmdir]]
 
[[Category:System Commands]]
 
[[Category:System Commands]]

Revision as of 06:28, 12 July 2005

Short for remove. Seriously, be careful when using this. There is no undelete once you've unlinked a file (unless you've aliased rm to a mv script that moves files to a trash folder or something -- which is not recommended because you will eventually find yourself on a system that doesn't have that alias and make a mistake.)

Common flags

-r recursive -- same as -R
-f force -- do it and damn the consequences
-d directories
-i confirm before delete
-P overwrite files (with 0xFF's, 0x00's, and 0xFF's again) before deleting them
-v be verbose

About the -P argument

Use this argument with extreme care! If you use rm -P to remove a file that has hard links, the file will be immediately overwritten and its contents will be lost, thus not accessible via the links. For example :

$ echo 'Hello World' > foo
$ ln -h foo bar
$ cat foo bar
Hello World
Hello World
$ rm -P foo
$ cat bar
$ Hey !! where is bar contents ??
Hey, command not found

See also rmdir

Personal tools