coreutils: rm invocation

1 
1 11.5 ‘rm’: Remove files or directories
1 ======================================
1 
1 ‘rm’ removes each given FILE.  By default, it does not remove
1 directories.  Synopsis:
1 
1      rm [OPTION]... [FILE]...
1 
1    If the ‘-I’ or ‘--interactive=once’ option is given, and there are
1 more than three files or the ‘-r’, ‘-R’, or ‘--recursive’ are given,
1 then ‘rm’ prompts the user for whether to proceed with the entire
1 operation.  If the response is not affirmative, the entire command is
1 aborted.
1 
1    Otherwise, if a file is unwritable, standard input is a terminal, and
1 the ‘-f’ or ‘--force’ option is not given, or the ‘-i’ or
1 ‘--interactive=always’ option _is_ given, ‘rm’ prompts the user for
1 whether to remove the file.  If the response is not affirmative, the
1 file is skipped.
1 
1    Any attempt to remove a file whose last file name component is ‘.’ or
1 ‘..’ is rejected without any prompting, as mandated by POSIX.
1 
1    _Warning_: If you use ‘rm’ to remove a file, it is usually possible
1 to recover the contents of that file.  If you want more assurance that
1 the contents are truly unrecoverable, consider using ‘shred’.
1 
11    The program accepts the following options.  Also see ⇒Common
 options.
1 
1 ‘-d’
1 ‘--dir’
1      Remove the listed directories if they are empty.
1 
1 ‘-f’
1 ‘--force’
1      Ignore nonexistent files and missing operands, and never prompt the
1      user.  Ignore any previous ‘--interactive’ (‘-i’) option.
1 
1 ‘-i’
1      Prompt whether to remove each file.  If the response is not
1      affirmative, the file is skipped.  Ignore any previous ‘--force’
1      (‘-f’) option.  Equivalent to ‘--interactive=always’.
1 
1 ‘-I’
1      Prompt once whether to proceed with the command, if more than three
1      files are named or if a recursive removal is requested.  Ignore any
1      previous ‘--force’ (‘-f’) option.  Equivalent to
1      ‘--interactive=once’.
1 
1 ‘--interactive [=WHEN]’
1      Specify when to issue an interactive prompt.  WHEN may be omitted,
1      or one of:
1         • never - Do not prompt at all.
1         • once - Prompt once if more than three files are named or if a
1           recursive removal is requested.  Equivalent to ‘-I’.
1         • always - Prompt for every file being removed.  Equivalent to
1           ‘-i’.
1      ‘--interactive’ with no WHEN is equivalent to
1      ‘--interactive=always’.
1 
1 ‘--one-file-system’
1      When removing a hierarchy recursively, skip any directory that is
1      on a file system different from that of the corresponding command
1      line argument.  This option is useful when removing a build
1      “chroot” hierarchy, which normally contains no valuable data.
1      However, it is not uncommon to bind-mount ‘/home’ into such a
1      hierarchy, to make it easier to use one’s start-up file.  The catch
1      is that it’s easy to forget to unmount ‘/home’.  Then, when you use
1      ‘rm -rf’ to remove your normally throw-away chroot, that command
1      will remove everything under ‘/home’, too.  Use the
1      ‘--one-file-system’ option, and it will warn about and skip
1      directories on other file systems.  Of course, this will not save
1      your ‘/home’ if it and your chroot happen to be on the same file
1      system.  See also ‘--preserve-root=all’ to protect command line
1      arguments themselves.
1 
1 ‘--preserve-root [=all]’
1      Fail upon any attempt to remove the root directory, ‘/’, when used
1      with the ‘--recursive’ option.  This is the default behavior.
1      ⇒Treating / specially.  When ‘all’ is specified, reject any
1      command line argument that is not on the same file system as its
1      parent.
1 
1 ‘--no-preserve-root’
1      Do not treat ‘/’ specially when removing recursively.  This option
1      is not recommended unless you really want to remove all the files
1      on your computer.  ⇒Treating / specially.
1 
1 ‘-r’
1 ‘-R’
1 ‘--recursive’
1      Remove the listed directories and their contents recursively.
1 
1 ‘-v’
1 ‘--verbose’
1      Print the name of each file before removing it.
1 
1    One common question is how to remove files whose names begin with a
1 ‘-’.  GNU ‘rm’, like every program that uses the ‘getopt’ function to
1 parse its arguments, lets you use the ‘--’ option to indicate that all
1 following arguments are non-options.  To remove a file called ‘-f’ in
1 the current directory, you could type either:
1 
1      rm -- -f
1 
1 or:
1 
1      rm ./-f
1 
1    The Unix ‘rm’ program’s use of a single ‘-’ for this purpose predates
1 the development of the ‘getopt’ standard syntax.
1 
1    An exit status of zero indicates success, and a nonzero value
1 indicates failure.
1