1.\" $OpenBSD: mv.1,v 1.34 2018/11/14 15:53:31 tedu Exp $ 2.\" $NetBSD: mv.1,v 1.8 1995/03/21 09:06:51 cgd Exp $ 3.\" 4.\" Copyright (c) 1989, 1990, 1993 5.\" The Regents of the University of California. All rights reserved. 6.\" 7.\" This code is derived from software contributed to Berkeley by 8.\" the Institute of Electrical and Electronics Engineers, Inc. 9.\" 10.\" Redistribution and use in source and binary forms, with or without 11.\" modification, are permitted provided that the following conditions 12.\" are met: 13.\" 1. Redistributions of source code must retain the above copyright 14.\" notice, this list of conditions and the following disclaimer. 15.\" 2. Redistributions in binary form must reproduce the above copyright 16.\" notice, this list of conditions and the following disclaimer in the 17.\" documentation and/or other materials provided with the distribution. 18.\" 3. Neither the name of the University nor the names of its contributors 19.\" may be used to endorse or promote products derived from this software 20.\" without specific prior written permission. 21.\" 22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32.\" SUCH DAMAGE. 33.\" 34.\" @(#)mv.1 8.1 (Berkeley) 5/31/93 35.\" 36.Dd $Mdocdate: November 14 2018 $ 37.Dt MV 1 38.Os 39.Sh NAME 40.Nm mv 41.Nd move files 42.Sh SYNOPSIS 43.Nm mv 44.Op Fl fiv 45.Ar source target 46.Nm mv 47.Op Fl fiv 48.Ar source ... directory 49.Sh DESCRIPTION 50In its first form, the 51.Nm 52utility moves the file named by the 53.Ar source 54operand to the destination path named by the 55.Ar target 56operand. 57This form is assumed when the last operand does not name an already 58existing directory. 59.Pp 60In its second form, 61.Nm 62moves each file named by a 63.Ar source 64operand to the destination specified by the 65.Ar directory 66operand. 67It is an error if the 68.Ar directory 69does not exist. 70The destination path for each 71.Ar source 72operand is the pathname produced by the concatenation of the 73.Ar directory 74operand, a slash, and the final pathname component of the named file. 75.Pp 76In both forms, a 77.Ar source 78operand is skipped with an error message 79when the respective destination path is a non-empty directory, 80or when the source is a non-directory file but the destination path 81is a directory, or vice versa. 82.Pp 83The options are as follows: 84.Bl -tag -width Ds 85.It Fl f 86Do not prompt for confirmation before overwriting the destination 87path. 88The 89.Fl f 90option overrides any previous 91.Fl i 92options. 93.It Fl i 94Causes 95.Nm 96to write a prompt to standard error before moving a file that would 97overwrite an existing file. 98If the response from the standard input begins with the character 99.Dq y , 100the move is attempted. 101The 102.Fl i 103option overrides any previous 104.Fl f 105options. 106.It Fl v 107Display the source and destination after each move. 108.El 109.Pp 110The 111.Nm 112utility moves symbolic links, not the files referenced by the links. 113.Pp 114If the destination path does not have a mode which permits writing, 115.Nm 116prompts the user for confirmation as specified for the 117.Fl i 118option. 119.Pp 120Should the 121.Xr rename 2 122call fail because the source and destination are on different file systems, 123.Nm 124will imitate 125.Xr cp 1 126and 127.Xr rm 1 128to accomplish the move. 129The effect is equivalent to: 130.Bd -literal -offset indent 131$ rm -df -- destination_path && \e 132 cp -PRp -- source destination_path && \e 133 rm -rf -- source 134.Ed 135.Sh EXIT STATUS 136.Ex -std mv 137.Sh EXAMPLES 138Rename file 139.Pa foo 140to 141.Pa bar , 142overwriting 143.Pa bar 144if it already exists: 145.Pp 146.Dl $ mv -f foo bar 147.Pp 148Either of these commands will rename the file 149.Pa -f 150to 151.Pa bar , 152prompting for confirmation if 153.Pa bar 154already exists: 155.Bd -literal -offset indent 156$ mv -i -- -f bar 157$ mv -i ./-f bar 158.Ed 159.Sh SEE ALSO 160.Xr cp 1 , 161.Xr rm 1 , 162.Xr rename 2 , 163.Xr symlink 7 164.Sh STANDARDS 165The 166.Nm 167utility is compliant with the 168.St -p1003.1-2008 169specification. 170.Pp 171The flag 172.Op Fl v 173is an extension to that specification. 174.Sh HISTORY 175A 176.Nm 177command appeared in 178.At v1 . 179.Sh CAVEATS 180In the second synopsis form, incompatible file types in 181.Ar source 182and 183.Ar directory 184cause partial moves. 185For example, if 186.Pa f 187and 188.Pa g 189are non-directory files and 190.Pa d 191and 192.Pa d/f 193are directories, the command 194.Pp 195.Dl $ mv f g d 196.Pp 197will print an error message, leave 198.Pa f 199where it is, move 200.Pa g 201to 202.Pa d/g 203and return a non-zero exit status. 204