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.\" Redistribution and use in source and binary forms, with or without 8.\" modification, are permitted provided that the following conditions 9.\" are met: 10.\" 1. Redistributions of source code must retain the above copyright 11.\" notice, this list of conditions and the following disclaimer. 12.\" 2. Redistributions in binary form must reproduce the above copyright 13.\" notice, this list of conditions and the following disclaimer in the 14.\" documentation and/or other materials provided with the distribution. 15.\" 3. All advertising materials mentioning features or use of this software 16.\" must display the following acknowledgement: 17.\" This product includes software developed by the University of 18.\" California, Berkeley and its contributors. 19.\" 4. Neither the name of the University nor the names of its contributors 20.\" may be used to endorse or promote products derived from this software 21.\" without specific prior written permission. 22.\" 23.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33.\" SUCH DAMAGE. 34.\" 35.\" @(#)rm.1 8.5 (Berkeley) 12/5/94 36.\" $FreeBSD: src/bin/rm/rm.1,v 1.19.2.6 2003/02/04 22:10:42 trhodes Exp $ 37.\" $DragonFly: src/bin/rm/rm.1,v 1.6 2005/06/03 16:00:23 dillon Exp $ 38.\" 39.Dd January 28, 1999 40.Dt RM 1 41.Os 42.Sh NAME 43.Nm rm , 44.Nm unlink 45.Nd remove directory entries 46.Sh SYNOPSIS 47.Nm 48.Op Fl dfiIPRrvW 49.Ar 50.Nm unlink 51.Ar file 52.Sh DESCRIPTION 53The 54.Nm 55utility attempts to remove the non-directory type files specified on the 56command line. 57If the permissions of the file do not permit writing, and the standard 58input device is a terminal, the user is prompted (on the standard error 59output) for confirmation. 60.Pp 61The options are as follows: 62.Bl -tag -width Fl 63.It Fl d 64Attempt to remove directories as well as other types of files. 65.It Fl f 66Attempt to remove the files without prompting for confirmation, 67regardless of the file's permissions. 68If the file does not exist, do not display a diagnostic message or modify 69the exit status to reflect an error. 70The 71.Fl f 72option overrides any previous 73.Fl i 74options. 75.It Fl i 76Request confirmation before attempting to remove each file, regardless of 77the file's permissions, or whether or not the standard input device is a 78terminal. 79The 80.Fl i 81option overrides any previous 82.Fl f 83options. 84.It Fl I 85Request confirmation once if more than three files are being removed or if a 86directory is being recursively removed. This option only applies when the 87.Nm 88utility is run in the foreground. 89This is a far less intrusive option than 90.Fl i 91yet provides almost the same level of protection against mistakes. 92.It Fl P 93Overwrite regular files before deleting them. 94Files are overwritten three times, first with the byte pattern 0xff, 95then 0x00, and then 0xff again, before they are deleted. 96.It Fl R 97Attempt to remove the file hierarchy rooted in each file argument. 98The 99.Fl R 100option implies the 101.Fl d 102option. 103If the 104.Fl i 105option is specified, the user is prompted for confirmation before 106each directory's contents are processed (as well as before the attempt 107is made to remove the directory). 108If the user does not respond affirmatively, the file hierarchy rooted in 109that directory is skipped. 110.Pp 111.It Fl r 112Equivalent to 113.Fl R . 114.It Fl v 115Be verbose when deleting files, showing them as they are removed. 116.It Fl W 117Attempt to undelete the named files. 118Currently, this option can only be used to recover 119files covered by whiteouts. 120.El 121.Pp 122The 123.Nm 124utility removes symbolic links, not the files referenced by the links. 125.Pp 126It is an error to attempt to remove the files 127.Dq .\& 128or 129.Dq .. . 130.Pp 131When the utility is called as 132.Nm unlink , 133only one argument, 134which must not be a directory, 135may be supplied. 136No options may be supplied in this simple mode of operation, 137which performs an 138.Xr unlink 2 139operation on the passed argument. 140.Pp 141The 142.Nm 143utility exits 0 if all of the named files or file hierarchies were removed, 144or if the 145.Fl f 146option was specified and all of the existing files or file hierarchies were 147removed. 148If an error occurs, 149.Nm 150exits with a value >0. 151.Sh NOTE 152The 153.Nm 154command uses 155.Xr getopt 3 156to parse its arguments, which allows it to accept 157the 158.Sq Li -- 159option which will cause it to stop processing flag options at that 160point. This will allow the removal of file names that begin 161with a dash 162.Pq Sq - . 163For example: 164.Dl rm -- -filename 165The same behavior can be obtained by using an absolute or relative 166path reference. For example: 167.Dl rm /home/user/-filename 168.Dl rm ./-filename 169.Sh SEE ALSO 170.Xr chflags 1 , 171.Xr rmdir 1 , 172.Xr undelete 2 , 173.Xr unlink 2 , 174.Xr fts 3 , 175.Xr getopt 3 , 176.Xr symlink 7 177.Sh BUGS 178The 179.Fl P 180option assumes that the underlying file system is a fixed-block file 181system. 182UFS is a fixed-block file system, LFS is not. 183In addition, only regular files are overwritten, other types of files 184are not. 185.Sh COMPATIBILITY 186The 187.Nm 188utility differs from historical implementations in that the 189.Fl f 190option only masks attempts to remove non-existent files instead of 191masking a large variety of errors. 192The 193.Fl v 194option is non-standard and its use in scripts is not recommended. 195.Pp 196Also, historical 197.Bx 198implementations prompted on the standard output, 199not the standard error output. 200.Sh STANDARDS 201The 202.Nm 203command conforms to 204.St -p1003.2 . 205.Pp 206The simplified 207.Nm unlink 208command conforms to 209.St -susv2 . 210.Sh HISTORY 211A 212.Nm 213command appeared in 214.At v1 . 215