1.\" Copyright (c) 1989, 1990, 1993 2.\" The Regents of the University of California. All rights reserved. 3.\" 4.\" This code is derived from software contributed to Berkeley by 5.\" the Institute of Electrical and Electronics Engineers, Inc. 6.\" 7.\" Redistribution and use in source and binary forms, with or without 8.\" modification, are permitted provided that the following conditions 9.\" are met: 10.\" 1. Redistributions of source code must retain the above copyright 11.\" notice, this list of conditions and the following disclaimer. 12.\" 2. Redistributions in binary form must reproduce the above copyright 13.\" notice, this list of conditions and the following disclaimer in the 14.\" documentation and/or other materials provided with the distribution. 15.\" 3. Neither the name of the University nor the names of its contributors 16.\" may be used to endorse or promote products derived from this software 17.\" without specific prior written permission. 18.\" 19.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29.\" SUCH DAMAGE. 30.\" 31.\" @(#)mv.1 8.1 (Berkeley) 5/31/93 32.\" $FreeBSD$ 33.\" 34.Dd November 16, 2012 35.Dt MV 1 36.Os 37.Sh NAME 38.Nm mv 39.Nd move files 40.Sh SYNOPSIS 41.Nm 42.Op Fl f | i | n 43.Op Fl hv 44.Ar source target 45.Nm 46.Op Fl f | i | n 47.Op Fl v 48.Ar source ... directory 49.Sh DESCRIPTION 50In its first form, the 51.Nm 52utility renames 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 a destination file in the existing directory named by the 65.Ar directory 66operand. 67The destination path for each operand is the pathname produced by the 68concatenation of the last operand, a slash, and the final pathname 69component of the named file. 70.Pp 71The following options are available: 72.Bl -tag -width indent 73.It Fl f 74Do not prompt for confirmation before overwriting the destination 75path. 76(The 77.Fl f 78option overrides any previous 79.Fl i 80or 81.Fl n 82options.) 83.It Fl h 84If the 85.Ar target 86operand is a symbolic link to a directory, 87do not follow it. 88This causes the 89.Nm 90utility to rename the file 91.Ar source 92to the destination path 93.Ar target 94rather than moving 95.Ar source 96into the directory referenced by 97.Ar target . 98.It Fl i 99Cause 100.Nm 101to write a prompt to standard error before moving a file that would 102overwrite an existing file. 103If the response from the standard input begins with the character 104.Ql y 105or 106.Ql Y , 107the move is attempted. 108(The 109.Fl i 110option overrides any previous 111.Fl f 112or 113.Fl n 114options.) 115.It Fl n 116Do not overwrite an existing file. 117(The 118.Fl n 119option overrides any previous 120.Fl f 121or 122.Fl i 123options.) 124.It Fl v 125Cause 126.Nm 127to be verbose, showing files after they are moved. 128.El 129.Pp 130It is an error for the 131.Ar source 132operand to specify a directory if the target exists and is not a directory. 133.Pp 134If the destination path does not have a mode which permits writing, 135.Nm 136prompts the user for confirmation as specified for the 137.Fl i 138option. 139.Pp 140As the 141.Xr rename 2 142call does not work across file systems, 143.Nm 144uses 145.Xr cp 1 146and 147.Xr rm 1 148to accomplish the move. 149The effect is equivalent to: 150.Bd -literal -offset indent 151rm -f destination_path && \e 152cp -pRP source_file destination && \e 153rm -rf source_file 154.Ed 155.Pp 156If 157.Nm 158receives a 159.Dv SIGINFO 160(see the 161.Cm status 162argument for 163.Xr stty 1 ) 164signal, the current input and output file 165will be written to standard error. 166.Sh EXIT STATUS 167.Ex -std 168.Sh COMPATIBILITY 169The 170.Fl h , 171.Fl n , 172and 173.Fl v 174options are non-standard and their use in scripts is not recommended. 175.Sh SEE ALSO 176.Xr cp 1 , 177.Xr rm 1 , 178.Xr symlink 7 179.Sh STANDARDS 180The 181.Nm 182utility is expected to be 183.St -p1003.2 184compatible. 185.Sh HISTORY 186A 187.Nm 188command appeared in 189.At v1 . 190