| 1 | .\" Copyright (c) 1990, 1993, 1994 |
| 2 | .\" The Regents of the University of California. All rights reserved. |
| 3 | .\" |
| 4 | .\" This code is derived from software contributed to Berkeley by |
| 5 | .\" the Institute of Electrical and Electronics Engineers, Inc. |
| 6 | .\" |
| 7 | .\" %sccs.include.redist.roff% |
| 8 | .\" |
| 9 | .\" @(#)rm.1 8.3 (Berkeley) %G% |
| 10 | .\" |
| 11 | .Dd |
| 12 | .Dt RM 1 |
| 13 | .Os |
| 14 | .Sh NAME |
| 15 | .Nm rm |
| 16 | .Nd remove directory entries |
| 17 | .Sh SYNOPSIS |
| 18 | .Nm rm |
| 19 | .Op Fl f | Fl i |
| 20 | .Op Fl dPRrW |
| 21 | .Ar file ... |
| 22 | .Sh DESCRIPTION |
| 23 | The |
| 24 | .Nm rm |
| 25 | utility attempts to remove the non-directory type files specified on the |
| 26 | command line. |
| 27 | If the permissions of the file do not permit writing, and the standard |
| 28 | input device is a terminal, the user is prompted (on the standard error |
| 29 | output) for confirmation. |
| 30 | .Pp |
| 31 | The options are as follows: |
| 32 | .Bl -tag -width flag |
| 33 | .It Fl d |
| 34 | Attempt to remove directories as well as other types of files. |
| 35 | .It Fl f |
| 36 | Attempt to remove the files without prompting for confirmation, |
| 37 | regardless of the file's permissions. |
| 38 | If the file does not exist, do not display a diagnostic message or modify |
| 39 | the exit status to reflect an error. |
| 40 | The |
| 41 | .Fl f |
| 42 | option overrides any previous |
| 43 | .Fl i |
| 44 | options. |
| 45 | .It Fl i |
| 46 | Request confirmation before attempting to remove each file, regardless of |
| 47 | the file's permissions, or whether or not the standard input device is a |
| 48 | terminal. |
| 49 | The |
| 50 | .Fl i |
| 51 | option overrides any previous |
| 52 | .Fl f |
| 53 | options. |
| 54 | .It Fl P |
| 55 | Overwrite regular files before deleting them. |
| 56 | Files are overwritten three times, first with the byte pattern 0xff, |
| 57 | then 0x00, and then 0xff again, before they are deleted. |
| 58 | .It Fl R |
| 59 | Attempt to remove the file hierarchy rooted in each file argument. |
| 60 | The |
| 61 | .Fl R |
| 62 | option implies the |
| 63 | .Fl d |
| 64 | option. |
| 65 | If the |
| 66 | .Fl i |
| 67 | option is specified, the user is prompted for confirmation before |
| 68 | each directory's contents are processed (as well as before the attempt |
| 69 | is made to remove the directory). |
| 70 | If the user does not respond affirmatively, the file hierarchy rooted in |
| 71 | that directory is skipped. |
| 72 | .Pp |
| 73 | .It Fl r |
| 74 | Equivalent to |
| 75 | .Fl R . |
| 76 | .It Fl W |
| 77 | Removes a whiteout. |
| 78 | .El |
| 79 | .Pp |
| 80 | The |
| 81 | .Nm rm |
| 82 | utility removes symbolic links, not the files referenced by the links. |
| 83 | .Pp |
| 84 | It is an error to attempt to remove the files ``.'' and ``..''. |
| 85 | .Pp |
| 86 | The |
| 87 | .Nm rm |
| 88 | utility exits 0 if all of the named files or file hierarchies were removed, |
| 89 | or if the |
| 90 | .Fl f |
| 91 | option was specified and all of the existing files or file hierarchies were |
| 92 | removed. |
| 93 | If an error occurs, |
| 94 | .Nm rm |
| 95 | exits with a value >0. |
| 96 | .Sh SEE ALSO |
| 97 | .Xr rmdir 1 , |
| 98 | .Xr unlink 2 , |
| 99 | .Xr unwhiteout 2 , |
| 100 | .Xr fts 3 , |
| 101 | .Xr symlink 7 |
| 102 | .Sh BUGS |
| 103 | The |
| 104 | .Fl P |
| 105 | option assumes that the underlying file system is a fixed-block file |
| 106 | system. |
| 107 | UFS is a fixed-block file system, LFS is not. |
| 108 | In addition, only regular files are overwritten, other types of files |
| 109 | are not. |
| 110 | .Sh COMPATIBILITY |
| 111 | The |
| 112 | .Nm rm |
| 113 | utility differs from historical implementations in that the |
| 114 | .Fl f |
| 115 | option only masks attempts to remove non-existent files instead of |
| 116 | masking a large variety of errors. |
| 117 | .Pp |
| 118 | Also, historical |
| 119 | .Bx |
| 120 | implementations prompted on the standard output, |
| 121 | not the standard error output. |
| 122 | .Sh STANDARDS |
| 123 | The |
| 124 | .Nm rm |
| 125 | command is expected to be |
| 126 | .St -p1003.2 |
| 127 | compatible. |