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. 16fbbd9655SWarner Losh.\" 3. 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.\" 32*900c4ed3SConrad Meyer.Dd November 10, 2018 334b88c807SRodney W. Grimes.Dt RM 1 344b88c807SRodney W. Grimes.Os 354b88c807SRodney W. Grimes.Sh NAME 36d71e172aSSheldon Hearn.Nm rm , 37d71e172aSSheldon Hearn.Nm unlink 384b88c807SRodney W. Grimes.Nd remove directory entries 394b88c807SRodney W. Grimes.Sh SYNOPSIS 40be8b1497SRuslan Ermilov.Nm 41a89237aeSRuslan Ermilov.Op Fl f | i 42*900c4ed3SConrad Meyer.Op Fl dIRrvWx 4347dec781SRuslan Ermilov.Ar 44d71e172aSSheldon Hearn.Nm unlink 4519b4f0dcSEd Maste.Op Fl - 46d71e172aSSheldon Hearn.Ar file 474b88c807SRodney W. Grimes.Sh DESCRIPTION 484b88c807SRodney W. GrimesThe 49f43e9d22SPhilippe Charnier.Nm 504b88c807SRodney W. Grimesutility attempts to remove the non-directory type files specified on the 514b88c807SRodney W. Grimescommand line. 524b88c807SRodney W. GrimesIf the permissions of the file do not permit writing, and the standard 534b88c807SRodney W. Grimesinput device is a terminal, the user is prompted (on the standard error 544b88c807SRodney W. Grimesoutput) for confirmation. 554b88c807SRodney W. Grimes.Pp 564b88c807SRodney W. GrimesThe options are as follows: 57ca3f81d8SRuslan Ermilov.Bl -tag -width indent 584b88c807SRodney W. Grimes.It Fl d 594b88c807SRodney W. GrimesAttempt to remove directories as well as other types of files. 604b88c807SRodney W. Grimes.It Fl f 614b88c807SRodney W. GrimesAttempt to remove the files without prompting for confirmation, 624b88c807SRodney W. Grimesregardless of the file's permissions. 634b88c807SRodney W. GrimesIf the file does not exist, do not display a diagnostic message or modify 644b88c807SRodney W. Grimesthe exit status to reflect an error. 654b88c807SRodney W. GrimesThe 664b88c807SRodney W. Grimes.Fl f 674b88c807SRodney W. Grimesoption overrides any previous 684b88c807SRodney W. Grimes.Fl i 694b88c807SRodney W. Grimesoptions. 704b88c807SRodney W. Grimes.It Fl i 714b88c807SRodney W. GrimesRequest confirmation before attempting to remove each file, regardless of 724b88c807SRodney W. Grimesthe file's permissions, or whether or not the standard input device is a 734b88c807SRodney W. Grimesterminal. 744b88c807SRodney W. GrimesThe 754b88c807SRodney W. Grimes.Fl i 764b88c807SRodney W. Grimesoption overrides any previous 774b88c807SRodney W. Grimes.Fl f 784b88c807SRodney W. Grimesoptions. 7924c0f738SXin LI.It Fl I 80164d3f0bSXin LIRequest confirmation once if more than three files are being removed or if a 81164d3f0bSXin LIdirectory is being recursively removed. 82164d3f0bSXin LIThis is a far less intrusive option than 8324c0f738SXin LI.Fl i 8424c0f738SXin LIyet provides almost the same level of protection against mistakes. 854b88c807SRodney W. Grimes.It Fl P 86*900c4ed3SConrad MeyerThis flag has no effect. 87*900c4ed3SConrad MeyerIt is kept only for backwards compatibility with 88*900c4ed3SConrad Meyer.Bx 4.4 Lite2 . 894b88c807SRodney W. Grimes.It Fl R 90ca3f81d8SRuslan ErmilovAttempt to remove the file hierarchy rooted in each 91ca3f81d8SRuslan Ermilov.Ar file 92ca3f81d8SRuslan Ermilovargument. 934b88c807SRodney W. GrimesThe 944b88c807SRodney W. Grimes.Fl R 954b88c807SRodney W. Grimesoption implies the 964b88c807SRodney W. Grimes.Fl d 974b88c807SRodney W. Grimesoption. 984b88c807SRodney W. GrimesIf the 994b88c807SRodney W. Grimes.Fl i 1004b88c807SRodney W. Grimesoption is specified, the user is prompted for confirmation before 1014b88c807SRodney W. Grimeseach directory's contents are processed (as well as before the attempt 1024b88c807SRodney W. Grimesis made to remove the directory). 1034b88c807SRodney W. GrimesIf the user does not respond affirmatively, the file hierarchy rooted in 1044b88c807SRodney W. Grimesthat directory is skipped. 1054b88c807SRodney W. Grimes.It Fl r 1064b88c807SRodney W. GrimesEquivalent to 1074b88c807SRodney W. Grimes.Fl R . 108777d1f82SMichael Haro.It Fl v 109777d1f82SMichael HaroBe verbose when deleting files, showing them as they are removed. 1101f64b5c9SSteve Price.It Fl W 111f43e9d22SPhilippe CharnierAttempt to undelete the named files. 1121f64b5c9SSteve PriceCurrently, this option can only be used to recover 11388b0915eSRuslan Ermilovfiles covered by whiteouts in a union file system (see 11488b0915eSRuslan Ermilov.Xr undelete 2 ) . 115d4319e74SEitan Adler.It Fl x 116d4319e74SEitan AdlerWhen removing a hierarchy, do not cross mount points. 1174b88c807SRodney W. Grimes.El 1184b88c807SRodney W. Grimes.Pp 1194b88c807SRodney W. GrimesThe 120f43e9d22SPhilippe Charnier.Nm 1214b88c807SRodney W. Grimesutility removes symbolic links, not the files referenced by the links. 1224b88c807SRodney W. Grimes.Pp 123f80db2b8SKris KennawayIt is an error to attempt to remove the files 1243a667dafSDag-Erling Smørgrav.Pa / , 1253a667dafSDag-Erling Smørgrav.Pa .\& 126f80db2b8SKris Kennawayor 1273a667dafSDag-Erling Smørgrav.Pa .. . 1284b88c807SRodney W. Grimes.Pp 129d71e172aSSheldon HearnWhen the utility is called as 130d71e172aSSheldon Hearn.Nm unlink , 131d71e172aSSheldon Hearnonly one argument, 132d71e172aSSheldon Hearnwhich must not be a directory, 133d71e172aSSheldon Hearnmay be supplied. 134d71e172aSSheldon HearnNo options may be supplied in this simple mode of operation, 1359a73cc73SSheldon Hearnwhich performs an 136d71e172aSSheldon Hearn.Xr unlink 2 1379a73cc73SSheldon Hearnoperation on the passed argument. 13819b4f0dcSEd MasteHowever, the usual option-end delimiter, 13919b4f0dcSEd Maste.Fl - , 14019b4f0dcSEd Mastemay optionally precede the argument. 141ca3f81d8SRuslan Ermilov.Sh EXIT STATUS 1424b88c807SRodney W. GrimesThe 143f43e9d22SPhilippe Charnier.Nm 1444b88c807SRodney W. Grimesutility exits 0 if all of the named files or file hierarchies were removed, 1454b88c807SRodney W. Grimesor if the 1464b88c807SRodney W. Grimes.Fl f 1474b88c807SRodney W. Grimesoption was specified and all of the existing files or file hierarchies were 1484b88c807SRodney W. Grimesremoved. 1494b88c807SRodney W. GrimesIf an error occurs, 150f43e9d22SPhilippe Charnier.Nm 1514b88c807SRodney W. Grimesexits with a value >0. 152ca3f81d8SRuslan Ermilov.Sh NOTES 153fe83da2eSMike PritchardThe 154fe83da2eSMike Pritchard.Nm 155fe83da2eSMike Pritchardcommand uses 156b0205affSWolfram Schneider.Xr getopt 3 157fe83da2eSMike Pritchardto parse its arguments, which allows it to accept 158fe83da2eSMike Pritchardthe 159b0205affSWolfram Schneider.Sq Li -- 160fe83da2eSMike Pritchardoption which will cause it to stop processing flag options at that 161eccea571SRuslan Ermilovpoint. 162eccea571SRuslan ErmilovThis will allow the removal of file names that begin 163fe83da2eSMike Pritchardwith a dash 164fe83da2eSMike Pritchard.Pq Sq - . 165fe83da2eSMike PritchardFor example: 166ca3f81d8SRuslan Ermilov.Pp 167ca3f81d8SRuslan Ermilov.Dl "rm -- -filename" 168ca3f81d8SRuslan Ermilov.Pp 169fa10160cSMike PritchardThe same behavior can be obtained by using an absolute or relative 170eccea571SRuslan Ermilovpath reference. 171eccea571SRuslan ErmilovFor example: 172ca3f81d8SRuslan Ermilov.Pp 173ca3f81d8SRuslan Ermilov.Dl "rm /home/user/-filename" 174ca3f81d8SRuslan Ermilov.Dl "rm ./-filename" 175e9e3a1abSJoel Dahl.Sh EXAMPLES 176e9e3a1abSJoel DahlRecursively remove all files contained within the 177e9e3a1abSJoel Dahl.Pa foobar 178e9e3a1abSJoel Dahldirectory hierarchy: 179e9e3a1abSJoel Dahl.Pp 180e9e3a1abSJoel Dahl.Dl $ rm -rf foobar 181e9e3a1abSJoel Dahl.Pp 18219b4f0dcSEd MasteAny of these commands will remove the file 183e9e3a1abSJoel Dahl.Pa -f : 184e9e3a1abSJoel Dahl.Bd -literal -offset indent 185e9e3a1abSJoel Dahl$ rm -- -f 186e9e3a1abSJoel Dahl$ rm ./-f 18719b4f0dcSEd Maste$ unlink -f 188e9e3a1abSJoel Dahl.Ed 1894b88c807SRodney W. Grimes.Sh COMPATIBILITY 1904b88c807SRodney W. GrimesThe 191f43e9d22SPhilippe Charnier.Nm 1924b88c807SRodney W. Grimesutility differs from historical implementations in that the 1934b88c807SRodney W. Grimes.Fl f 1944b88c807SRodney W. Grimesoption only masks attempts to remove non-existent files instead of 1954b88c807SRodney W. Grimesmasking a large variety of errors. 196777d1f82SMichael HaroThe 197777d1f82SMichael Haro.Fl v 198777d1f82SMichael Harooption is non-standard and its use in scripts is not recommended. 1994b88c807SRodney W. Grimes.Pp 2004b88c807SRodney W. GrimesAlso, historical 2014b88c807SRodney W. Grimes.Bx 2024b88c807SRodney W. Grimesimplementations prompted on the standard output, 2034b88c807SRodney W. Grimesnot the standard error output. 204*900c4ed3SConrad Meyer.Pp 205*900c4ed3SConrad MeyerThe 206*900c4ed3SConrad Meyer.Fl P 207*900c4ed3SConrad Meyeroption does not have any effect as of 208*900c4ed3SConrad Meyer.Fx 13 209*900c4ed3SConrad Meyerand may be removed in the future. 2106fca4c7cSRuslan Ermilov.Sh SEE ALSO 2116fca4c7cSRuslan Ermilov.Xr chflags 1 , 2126fca4c7cSRuslan Ermilov.Xr rmdir 1 , 2136fca4c7cSRuslan Ermilov.Xr undelete 2 , 2146fca4c7cSRuslan Ermilov.Xr unlink 2 , 2156fca4c7cSRuslan Ermilov.Xr fts 3 , 2166fca4c7cSRuslan Ermilov.Xr getopt 3 , 2176fca4c7cSRuslan Ermilov.Xr symlink 7 2184b88c807SRodney W. Grimes.Sh STANDARDS 2194b88c807SRodney W. GrimesThe 220f43e9d22SPhilippe Charnier.Nm 22105519408SDoug Whitecommand conforms to 2228e5c71e2SBaptiste Daroussin.St -p1003.1-2013 . 2239a73cc73SSheldon Hearn.Pp 2249a73cc73SSheldon HearnThe simplified 2259a73cc73SSheldon Hearn.Nm unlink 2269a73cc73SSheldon Hearncommand conforms to 2279a73cc73SSheldon Hearn.St -susv2 . 228b8923d4cSWolfram Schneider.Sh HISTORY 229b8923d4cSWolfram SchneiderA 230b8923d4cSWolfram Schneider.Nm 231b8923d4cSWolfram Schneidercommand appeared in 232b8923d4cSWolfram Schneider.At v1 . 233