19ddb49cbSWarner Losh.\"- 24b88c807SRodney W. Grimes.\" Copyright (c) 1990, 1993, 1994 34b88c807SRodney W. Grimes.\" The Regents of the University of California. All rights reserved. 44b88c807SRodney W. Grimes.\" 54b88c807SRodney W. Grimes.\" This code is derived from software contributed to Berkeley by 64b88c807SRodney W. Grimes.\" the Institute of Electrical and Electronics Engineers, Inc. 74b88c807SRodney W. Grimes.\" 84b88c807SRodney W. Grimes.\" Redistribution and use in source and binary forms, with or without 94b88c807SRodney W. Grimes.\" modification, are permitted provided that the following conditions 104b88c807SRodney W. Grimes.\" are met: 114b88c807SRodney W. Grimes.\" 1. Redistributions of source code must retain the above copyright 124b88c807SRodney W. Grimes.\" notice, this list of conditions and the following disclaimer. 134b88c807SRodney W. Grimes.\" 2. Redistributions in binary form must reproduce the above copyright 144b88c807SRodney W. Grimes.\" notice, this list of conditions and the following disclaimer in the 154b88c807SRodney W. Grimes.\" documentation and/or other materials provided with the distribution. 164b88c807SRodney W. Grimes.\" 4. Neither the name of the University nor the names of its contributors 174b88c807SRodney W. Grimes.\" may be used to endorse or promote products derived from this software 184b88c807SRodney W. Grimes.\" without specific prior written permission. 194b88c807SRodney W. Grimes.\" 204b88c807SRodney W. Grimes.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 214b88c807SRodney W. Grimes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 224b88c807SRodney W. Grimes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 234b88c807SRodney W. Grimes.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 244b88c807SRodney W. Grimes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 254b88c807SRodney W. Grimes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 264b88c807SRodney W. Grimes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 274b88c807SRodney W. Grimes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 284b88c807SRodney W. Grimes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 294b88c807SRodney W. Grimes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 304b88c807SRodney W. Grimes.\" SUCH DAMAGE. 314b88c807SRodney W. Grimes.\" 321f64b5c9SSteve Price.\" @(#)rm.1 8.5 (Berkeley) 12/5/94 332a456239SPeter Wemm.\" $FreeBSD$ 344b88c807SRodney W. Grimes.\" 350b6f55b7SXin LI.Dd October 30, 2006 364b88c807SRodney W. Grimes.Dt RM 1 374b88c807SRodney W. Grimes.Os 384b88c807SRodney W. Grimes.Sh NAME 39d71e172aSSheldon Hearn.Nm rm , 40d71e172aSSheldon Hearn.Nm unlink 414b88c807SRodney W. Grimes.Nd remove directory entries 424b88c807SRodney W. Grimes.Sh SYNOPSIS 43be8b1497SRuslan Ermilov.Nm 44a89237aeSRuslan Ermilov.Op Fl f | i 45a89237aeSRuslan Ermilov.Op Fl dIPRrvW 4647dec781SRuslan Ermilov.Ar 47d71e172aSSheldon Hearn.Nm unlink 48d71e172aSSheldon Hearn.Ar file 494b88c807SRodney W. Grimes.Sh DESCRIPTION 504b88c807SRodney W. GrimesThe 51f43e9d22SPhilippe Charnier.Nm 524b88c807SRodney W. Grimesutility attempts to remove the non-directory type files specified on the 534b88c807SRodney W. Grimescommand line. 544b88c807SRodney W. GrimesIf the permissions of the file do not permit writing, and the standard 554b88c807SRodney W. Grimesinput device is a terminal, the user is prompted (on the standard error 564b88c807SRodney W. Grimesoutput) for confirmation. 574b88c807SRodney W. Grimes.Pp 584b88c807SRodney W. GrimesThe options are as follows: 59ca3f81d8SRuslan Ermilov.Bl -tag -width indent 604b88c807SRodney W. Grimes.It Fl d 614b88c807SRodney W. GrimesAttempt to remove directories as well as other types of files. 624b88c807SRodney W. Grimes.It Fl f 634b88c807SRodney W. GrimesAttempt to remove the files without prompting for confirmation, 644b88c807SRodney W. Grimesregardless of the file's permissions. 654b88c807SRodney W. GrimesIf the file does not exist, do not display a diagnostic message or modify 664b88c807SRodney W. Grimesthe exit status to reflect an error. 674b88c807SRodney W. GrimesThe 684b88c807SRodney W. Grimes.Fl f 694b88c807SRodney W. Grimesoption overrides any previous 704b88c807SRodney W. Grimes.Fl i 714b88c807SRodney W. Grimesoptions. 724b88c807SRodney W. Grimes.It Fl i 734b88c807SRodney W. GrimesRequest confirmation before attempting to remove each file, regardless of 744b88c807SRodney W. Grimesthe file's permissions, or whether or not the standard input device is a 754b88c807SRodney W. Grimesterminal. 764b88c807SRodney W. GrimesThe 774b88c807SRodney W. Grimes.Fl i 784b88c807SRodney W. Grimesoption overrides any previous 794b88c807SRodney W. Grimes.Fl f 804b88c807SRodney W. Grimesoptions. 8124c0f738SXin LI.It Fl I 82164d3f0bSXin LIRequest confirmation once if more than three files are being removed or if a 83164d3f0bSXin LIdirectory is being recursively removed. 84164d3f0bSXin LIThis is a far less intrusive option than 8524c0f738SXin LI.Fl i 8624c0f738SXin LIyet provides almost the same level of protection against mistakes. 874b88c807SRodney W. Grimes.It Fl P 884b88c807SRodney W. GrimesOverwrite regular files before deleting them. 894b88c807SRodney W. GrimesFiles are overwritten three times, first with the byte pattern 0xff, 904b88c807SRodney W. Grimesthen 0x00, and then 0xff again, before they are deleted. 9186da4a5eSXin LIFiles with multiple links will not be overwritten nor deleted unless 9286da4a5eSXin LI.Fl f 9386da4a5eSXin LIis specified, a warning is generated instead. 940b6f55b7SXin LI.Pp 95a5f62950SDoug BartonSpecifying this flag for a read only file will cause 96a5f62950SDoug Barton.Nm 97a5f62950SDoug Bartonto generate an error message and exit. 988af11131SRuslan ErmilovThe file will not be removed or overwritten. 994b88c807SRodney W. Grimes.It Fl R 100ca3f81d8SRuslan ErmilovAttempt to remove the file hierarchy rooted in each 101ca3f81d8SRuslan Ermilov.Ar file 102ca3f81d8SRuslan Ermilovargument. 1034b88c807SRodney W. GrimesThe 1044b88c807SRodney W. Grimes.Fl R 1054b88c807SRodney W. Grimesoption implies the 1064b88c807SRodney W. Grimes.Fl d 1074b88c807SRodney W. Grimesoption. 1084b88c807SRodney W. GrimesIf the 1094b88c807SRodney W. Grimes.Fl i 1104b88c807SRodney W. Grimesoption is specified, the user is prompted for confirmation before 1114b88c807SRodney W. Grimeseach directory's contents are processed (as well as before the attempt 1124b88c807SRodney W. Grimesis made to remove the directory). 1134b88c807SRodney W. GrimesIf the user does not respond affirmatively, the file hierarchy rooted in 1144b88c807SRodney W. Grimesthat directory is skipped. 1154b88c807SRodney W. Grimes.Pp 1164b88c807SRodney W. Grimes.It Fl r 1174b88c807SRodney W. GrimesEquivalent to 1184b88c807SRodney W. Grimes.Fl R . 119777d1f82SMichael Haro.It Fl v 120777d1f82SMichael HaroBe verbose when deleting files, showing them as they are removed. 1211f64b5c9SSteve Price.It Fl W 122f43e9d22SPhilippe CharnierAttempt to undelete the named files. 1231f64b5c9SSteve PriceCurrently, this option can only be used to recover 124e9dff556SDoug Rabsonfiles covered by whiteouts. 1254b88c807SRodney W. Grimes.El 1264b88c807SRodney W. Grimes.Pp 1274b88c807SRodney W. GrimesThe 128f43e9d22SPhilippe Charnier.Nm 1294b88c807SRodney W. Grimesutility removes symbolic links, not the files referenced by the links. 1304b88c807SRodney W. Grimes.Pp 131f80db2b8SKris KennawayIt is an error to attempt to remove the files 1323a667dafSDag-Erling Smørgrav.Pa / , 1333a667dafSDag-Erling Smørgrav.Pa .\& 134f80db2b8SKris Kennawayor 1353a667dafSDag-Erling Smørgrav.Pa .. . 1364b88c807SRodney W. Grimes.Pp 137d71e172aSSheldon HearnWhen the utility is called as 138d71e172aSSheldon Hearn.Nm unlink , 139d71e172aSSheldon Hearnonly one argument, 140d71e172aSSheldon Hearnwhich must not be a directory, 141d71e172aSSheldon Hearnmay be supplied. 142d71e172aSSheldon HearnNo options may be supplied in this simple mode of operation, 1439a73cc73SSheldon Hearnwhich performs an 144d71e172aSSheldon Hearn.Xr unlink 2 1459a73cc73SSheldon Hearnoperation on the passed argument. 146ca3f81d8SRuslan Ermilov.Sh EXIT STATUS 1474b88c807SRodney W. GrimesThe 148f43e9d22SPhilippe Charnier.Nm 1494b88c807SRodney W. Grimesutility exits 0 if all of the named files or file hierarchies were removed, 1504b88c807SRodney W. Grimesor if the 1514b88c807SRodney W. Grimes.Fl f 1524b88c807SRodney W. Grimesoption was specified and all of the existing files or file hierarchies were 1534b88c807SRodney W. Grimesremoved. 1544b88c807SRodney W. GrimesIf an error occurs, 155f43e9d22SPhilippe Charnier.Nm 1564b88c807SRodney W. Grimesexits with a value >0. 157ca3f81d8SRuslan Ermilov.Sh NOTES 158fe83da2eSMike PritchardThe 159fe83da2eSMike Pritchard.Nm 160fe83da2eSMike Pritchardcommand uses 161b0205affSWolfram Schneider.Xr getopt 3 162fe83da2eSMike Pritchardto parse its arguments, which allows it to accept 163fe83da2eSMike Pritchardthe 164b0205affSWolfram Schneider.Sq Li -- 165fe83da2eSMike Pritchardoption which will cause it to stop processing flag options at that 166eccea571SRuslan Ermilovpoint. 167eccea571SRuslan ErmilovThis will allow the removal of file names that begin 168fe83da2eSMike Pritchardwith a dash 169fe83da2eSMike Pritchard.Pq Sq - . 170fe83da2eSMike PritchardFor example: 171ca3f81d8SRuslan Ermilov.Pp 172ca3f81d8SRuslan Ermilov.Dl "rm -- -filename" 173ca3f81d8SRuslan Ermilov.Pp 174fa10160cSMike PritchardThe same behavior can be obtained by using an absolute or relative 175eccea571SRuslan Ermilovpath reference. 176eccea571SRuslan ErmilovFor example: 177ca3f81d8SRuslan Ermilov.Pp 178ca3f81d8SRuslan Ermilov.Dl "rm /home/user/-filename" 179ca3f81d8SRuslan Ermilov.Dl "rm ./-filename" 18086da4a5eSXin LI.Pp 18186da4a5eSXin LIWhen 18286da4a5eSXin LI.Fl P 18386da4a5eSXin LIis specified with 18486da4a5eSXin LI.Fl f 18586da4a5eSXin LIthe file will be overwritten and removed even if it has hard links. 1864b88c807SRodney W. Grimes.Sh COMPATIBILITY 1874b88c807SRodney W. GrimesThe 188f43e9d22SPhilippe Charnier.Nm 1894b88c807SRodney W. Grimesutility differs from historical implementations in that the 1904b88c807SRodney W. Grimes.Fl f 1914b88c807SRodney W. Grimesoption only masks attempts to remove non-existent files instead of 1924b88c807SRodney W. Grimesmasking a large variety of errors. 193777d1f82SMichael HaroThe 194777d1f82SMichael Haro.Fl v 195777d1f82SMichael Harooption is non-standard and its use in scripts is not recommended. 1964b88c807SRodney W. Grimes.Pp 1974b88c807SRodney W. GrimesAlso, historical 1984b88c807SRodney W. Grimes.Bx 1994b88c807SRodney W. Grimesimplementations prompted on the standard output, 2004b88c807SRodney W. Grimesnot the standard error output. 2016fca4c7cSRuslan Ermilov.Sh SEE ALSO 2026fca4c7cSRuslan Ermilov.Xr chflags 1 , 2036fca4c7cSRuslan Ermilov.Xr rmdir 1 , 2046fca4c7cSRuslan Ermilov.Xr undelete 2 , 2056fca4c7cSRuslan Ermilov.Xr unlink 2 , 2066fca4c7cSRuslan Ermilov.Xr fts 3 , 2076fca4c7cSRuslan Ermilov.Xr getopt 3 , 2086fca4c7cSRuslan Ermilov.Xr symlink 7 2094b88c807SRodney W. Grimes.Sh STANDARDS 2104b88c807SRodney W. GrimesThe 211f43e9d22SPhilippe Charnier.Nm 21205519408SDoug Whitecommand conforms to 21305519408SDoug White.St -p1003.2 . 2149a73cc73SSheldon Hearn.Pp 2159a73cc73SSheldon HearnThe simplified 2169a73cc73SSheldon Hearn.Nm unlink 2179a73cc73SSheldon Hearncommand conforms to 2189a73cc73SSheldon Hearn.St -susv2 . 219b8923d4cSWolfram Schneider.Sh HISTORY 220b8923d4cSWolfram SchneiderA 221b8923d4cSWolfram Schneider.Nm 222b8923d4cSWolfram Schneidercommand appeared in 223b8923d4cSWolfram Schneider.At v1 . 2246fca4c7cSRuslan Ermilov.Sh BUGS 2256fca4c7cSRuslan ErmilovThe 2266fca4c7cSRuslan Ermilov.Fl P 2276fca4c7cSRuslan Ermilovoption assumes that the underlying file system is a fixed-block file 2286fca4c7cSRuslan Ermilovsystem. 2296fca4c7cSRuslan ErmilovUFS is a fixed-block file system, LFS is not. 2306fca4c7cSRuslan ErmilovIn addition, only regular files are overwritten, other types of files 2316fca4c7cSRuslan Ermilovare not. 232