1.\" $NetBSD: mv.1,v 1.32 2020/06/24 17:00:58 riastradh 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. Neither the name of the University nor the names of its contributors 18.\" may be used to endorse or promote products derived from this software 19.\" without specific prior written permission. 20.\" 21.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31.\" SUCH DAMAGE. 32.\" 33.\" @(#)mv.1 8.1 (Berkeley) 5/31/93 34.\" 35.Dd June 24, 2020 36.Dt MV 1 37.Os 38.Sh NAME 39.Nm mv 40.Nd move files 41.Sh SYNOPSIS 42.Nm 43.Op Fl fhiv 44.Ar source target 45.Nm 46.Op Fl fiv 47.Ar source ... directory 48.Sh DESCRIPTION 49In its first form, the 50.Nm 51utility renames the file named by the 52.Ar source 53operand to the destination path named by the 54.Ar target 55operand. 56This form is assumed when the last operand does not name an already 57existing directory or when the 58.Fl h 59flag is specified. 60.Pp 61In its second form, 62.Nm 63moves each file named by a 64.Ar source 65operand to a destination file in the existing directory named by the 66.Ar directory 67operand. 68The destination path for each operand is the pathname produced by the 69concatenation of the last operand, a slash, and the final pathname 70component of the named file. 71.Pp 72The following options are available: 73.Bl -tag -width flag 74.It Fl f 75Do not prompt for confirmation before overwriting the destination 76path. 77.It Fl h 78Try to rename the source to the target irrespective of whether the 79target may resolve to a directory. 80This option allows atomically replacing a symbolic link to a 81directory. 82.It Fl i 83Causes 84.Nm 85to write a prompt to standard error before moving a file that would 86overwrite an existing file. 87If the response from the standard input begins with the character ``y'', 88the move is attempted. 89.It Fl v 90Cause 91.Nm 92to be verbose, showing files as they are processed. 93.El 94.Pp 95The last of any 96.Fl f 97or 98.Fl i 99options is the one which affects 100.Nm Ns 's 101behavior. 102.Pp 103It is an error for any of the 104.Ar source 105operands to specify a nonexistent file or directory. 106.Pp 107It is an error for the 108.Ar source 109operand to specify a directory if the 110.Ar target 111exists and is not a directory. 112.Pp 113If the destination path does not have a mode which permits writing, 114.Nm 115prompts the user for confirmation as specified for the 116.Fl i 117option. 118.Pp 119Should the 120.Xr rename 2 121call fail because 122.Ar source 123and 124.Ar target 125are on different file systems, 126.Nm 127will remove the destination file, copy the source file to the 128destination, and then remove the source. 129The effect is roughly equivalent to: 130.Bd -literal -offset indent 131rm -f destination_path && \e 132cp -PRp source_file destination_path && \e 133rm -rf source_file 134.Ed 135.Sh EXIT STATUS 136.Ex -std mv 137.Sh SEE ALSO 138.Xr cp 1 , 139.Xr rename 2 , 140.Xr symlink 7 141.Sh STANDARDS 142The 143.Nm 144utility is expected to be 145.St -p1003.2 146compatible. 147.Pp 148The 149.Fl h 150and 151.Fl v 152options are extensions to 153.St -p1003.2 . 154.Sh HISTORY 155An 156.Nm 157utility appeared in 158.At v1 . 159