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.\" 3524c0f738SXin LI.Dd October 28, 2004 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: 59bd98a815SGarrett Wollman.Bl -tag -width Fl 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. 914b88c807SRodney W. Grimes.It Fl R 924b88c807SRodney W. GrimesAttempt to remove the file hierarchy rooted in each file argument. 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.Pp 1064b88c807SRodney W. Grimes.It Fl r 1074b88c807SRodney W. GrimesEquivalent to 1084b88c807SRodney W. Grimes.Fl R . 109777d1f82SMichael Haro.It Fl v 110777d1f82SMichael HaroBe verbose when deleting files, showing them as they are removed. 1111f64b5c9SSteve Price.It Fl W 112f43e9d22SPhilippe CharnierAttempt to undelete the named files. 1131f64b5c9SSteve PriceCurrently, this option can only be used to recover 114e9dff556SDoug Rabsonfiles covered by whiteouts. 1154b88c807SRodney W. Grimes.El 1164b88c807SRodney W. Grimes.Pp 1174b88c807SRodney W. GrimesThe 118f43e9d22SPhilippe Charnier.Nm 1194b88c807SRodney W. Grimesutility removes symbolic links, not the files referenced by the links. 1204b88c807SRodney W. Grimes.Pp 121f80db2b8SKris KennawayIt is an error to attempt to remove the files 1223a667dafSDag-Erling Smørgrav.Pa / , 1233a667dafSDag-Erling Smørgrav.Pa .\& 124f80db2b8SKris Kennawayor 1253a667dafSDag-Erling Smørgrav.Pa .. . 1264b88c807SRodney W. Grimes.Pp 127d71e172aSSheldon HearnWhen the utility is called as 128d71e172aSSheldon Hearn.Nm unlink , 129d71e172aSSheldon Hearnonly one argument, 130d71e172aSSheldon Hearnwhich must not be a directory, 131d71e172aSSheldon Hearnmay be supplied. 132d71e172aSSheldon HearnNo options may be supplied in this simple mode of operation, 1339a73cc73SSheldon Hearnwhich performs an 134d71e172aSSheldon Hearn.Xr unlink 2 1359a73cc73SSheldon Hearnoperation on the passed argument. 136d71e172aSSheldon Hearn.Pp 1374b88c807SRodney W. GrimesThe 138f43e9d22SPhilippe Charnier.Nm 1394b88c807SRodney W. Grimesutility exits 0 if all of the named files or file hierarchies were removed, 1404b88c807SRodney W. Grimesor if the 1414b88c807SRodney W. Grimes.Fl f 1424b88c807SRodney W. Grimesoption was specified and all of the existing files or file hierarchies were 1434b88c807SRodney W. Grimesremoved. 1444b88c807SRodney W. GrimesIf an error occurs, 145f43e9d22SPhilippe Charnier.Nm 1464b88c807SRodney W. Grimesexits with a value >0. 147b0205affSWolfram Schneider.Sh NOTE 148fe83da2eSMike PritchardThe 149fe83da2eSMike Pritchard.Nm 150fe83da2eSMike Pritchardcommand uses 151b0205affSWolfram Schneider.Xr getopt 3 152fe83da2eSMike Pritchardto parse its arguments, which allows it to accept 153fe83da2eSMike Pritchardthe 154b0205affSWolfram Schneider.Sq Li -- 155fe83da2eSMike Pritchardoption which will cause it to stop processing flag options at that 156eccea571SRuslan Ermilovpoint. 157eccea571SRuslan ErmilovThis will allow the removal of file names that begin 158fe83da2eSMike Pritchardwith a dash 159fe83da2eSMike Pritchard.Pq Sq - . 160fe83da2eSMike PritchardFor example: 161fe83da2eSMike Pritchard.Dl rm -- -filename 162fa10160cSMike PritchardThe same behavior can be obtained by using an absolute or relative 163eccea571SRuslan Ermilovpath reference. 164eccea571SRuslan ErmilovFor example: 165fa10160cSMike Pritchard.Dl rm /home/user/-filename 166fa10160cSMike Pritchard.Dl rm ./-filename 1674b88c807SRodney W. Grimes.Sh COMPATIBILITY 1684b88c807SRodney W. GrimesThe 169f43e9d22SPhilippe Charnier.Nm 1704b88c807SRodney W. Grimesutility differs from historical implementations in that the 1714b88c807SRodney W. Grimes.Fl f 1724b88c807SRodney W. Grimesoption only masks attempts to remove non-existent files instead of 1734b88c807SRodney W. Grimesmasking a large variety of errors. 174777d1f82SMichael HaroThe 175777d1f82SMichael Haro.Fl v 176777d1f82SMichael Harooption is non-standard and its use in scripts is not recommended. 1774b88c807SRodney W. Grimes.Pp 1784b88c807SRodney W. GrimesAlso, historical 1794b88c807SRodney W. Grimes.Bx 1804b88c807SRodney W. Grimesimplementations prompted on the standard output, 1814b88c807SRodney W. Grimesnot the standard error output. 1826fca4c7cSRuslan Ermilov.Sh SEE ALSO 1836fca4c7cSRuslan Ermilov.Xr chflags 1 , 1846fca4c7cSRuslan Ermilov.Xr rmdir 1 , 1856fca4c7cSRuslan Ermilov.Xr undelete 2 , 1866fca4c7cSRuslan Ermilov.Xr unlink 2 , 1876fca4c7cSRuslan Ermilov.Xr fts 3 , 1886fca4c7cSRuslan Ermilov.Xr getopt 3 , 1896fca4c7cSRuslan Ermilov.Xr symlink 7 1904b88c807SRodney W. Grimes.Sh STANDARDS 1914b88c807SRodney W. GrimesThe 192f43e9d22SPhilippe Charnier.Nm 19305519408SDoug Whitecommand conforms to 19405519408SDoug White.St -p1003.2 . 1959a73cc73SSheldon Hearn.Pp 1969a73cc73SSheldon HearnThe simplified 1979a73cc73SSheldon Hearn.Nm unlink 1989a73cc73SSheldon Hearncommand conforms to 1999a73cc73SSheldon Hearn.St -susv2 . 200b8923d4cSWolfram Schneider.Sh HISTORY 201b8923d4cSWolfram SchneiderA 202b8923d4cSWolfram Schneider.Nm 203b8923d4cSWolfram Schneidercommand appeared in 204b8923d4cSWolfram Schneider.At v1 . 2056fca4c7cSRuslan Ermilov.Sh BUGS 2066fca4c7cSRuslan ErmilovThe 2076fca4c7cSRuslan Ermilov.Fl P 2086fca4c7cSRuslan Ermilovoption assumes that the underlying file system is a fixed-block file 2096fca4c7cSRuslan Ermilovsystem. 2106fca4c7cSRuslan ErmilovUFS is a fixed-block file system, LFS is not. 2116fca4c7cSRuslan ErmilovIn addition, only regular files are overwritten, other types of files 2126fca4c7cSRuslan Ermilovare not. 213