1.\" $NetBSD: mv.1,v 1.18 2002/02/08 01:21:58 ross Exp $ 2.\" 3.\" Copyright (c) 1989, 1990, 1993 4.\" The Regents of the University of California. All rights reserved. 5.\" 6.\" This code is derived from software contributed to Berkeley by 7.\" the Institute of Electrical and Electronics Engineers, Inc. 8.\" 9.\" Redistribution and use in source and binary forms, with or without 10.\" modification, are permitted provided that the following conditions 11.\" are met: 12.\" 1. Redistributions of source code must retain the above copyright 13.\" notice, this list of conditions and the following disclaimer. 14.\" 2. Redistributions in binary form must reproduce the above copyright 15.\" notice, this list of conditions and the following disclaimer in the 16.\" documentation and/or other materials provided with the distribution. 17.\" 3. All advertising materials mentioning features or use of this software 18.\" must display the following acknowledgement: 19.\" This product includes software developed by the University of 20.\" California, Berkeley and its contributors. 21.\" 4. Neither the name of the University nor the names of its contributors 22.\" may be used to endorse or promote products derived from this software 23.\" without specific prior written permission. 24.\" 25.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 26.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 29.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 30.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 31.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 32.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 34.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35.\" SUCH DAMAGE. 36.\" 37.\" @(#)mv.1 8.1 (Berkeley) 5/31/93 38.\" 39.Dd May 31, 1993 40.Dt MV 1 41.Os 42.Sh NAME 43.Nm mv 44.Nd move files 45.Sh SYNOPSIS 46.Nm 47.Op Fl fi 48.Ar source target 49.Nm "" 50.Op Fl fi 51.Ar source ... directory 52.Sh DESCRIPTION 53In its first form, the 54.Nm 55utility renames the file named by the 56.Ar source 57operand to the destination path named by the 58.Ar target 59operand. 60This form is assumed when the last operand does not name an already 61existing directory. 62.Pp 63In its second form, 64.Nm 65moves each file named by a 66.Ar source 67operand to a destination file in the existing directory named by the 68.Ar directory 69operand. 70The destination path for each operand is the pathname produced by the 71concatenation of the last operand, a slash, and the final pathname 72component of the named file. 73.Pp 74The following options are available: 75.Bl -tag -width flag 76.It Fl f 77Do not prompt for confirmation before overwriting the destination 78path. 79.It Fl i 80Causes 81.Nm 82to write a prompt to standard error before moving a file that would 83overwrite an existing file. 84If the response from the standard input begins with the character ``y'', 85the move is attempted. 86.El 87The last of any 88.Fl f 89or 90.Fl i 91options is the one which affects 92.Nm Ns 's 93behavior. 94.Pp 95It is an error for any of the 96.Ar source 97operands to specify a nonexistent file or directory. 98.Pp 99It is an error for the 100.Ar source 101operand to specify a directory if the 102.Ar target 103exists and is not a directory. 104.Pp 105If the destination path does not have a mode which permits writing, 106.Nm 107prompts the user for confirmation as specified for the 108.Fl i 109option. 110.Pp 111Should the 112.Xr rename 2 113call fail because 114.Ar source 115and 116.Ar target 117are on different file systems, 118.Nm 119will remove the destination file, copy the source file to the 120destination, and then remove the source. 121The effect is roughly equivalent to: 122.Bd -literal -offset indent 123rm -f destination_path \*[Am]\*[Am] \e 124\tcp -PRp source_file destination_path \*[Am]\*[Am] \e 125\trm -rf source_file 126.Ed 127.Sh EXIT STATUS 128The 129.Nm 130utility exits 0 on success, and \*[Gt]0 if an error occurs. 131.Sh SEE ALSO 132.Xr cp 1 , 133.Xr rename 2 , 134.Xr symlink 7 135.Sh STANDARDS 136The 137.Nm 138utility is expected to be 139.St -p1003.2 140compatible. 141