2 .\" Copyright 1989 AT&T
3 .\" Copyright (c) 1992, X/Open Company Limited All Rights Reserved
4 .\" Portions Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved
5 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
6 .\" http://www.opengroup.org/bookstore/.
7 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
8 .\" This notice shall appear on any product containing this material.
9 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
10 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
11 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
12 .TH MV 1 "Oct 25, 2017"
18 \fB/usr/bin/mv\fR [\fB-fi\fR] \fIsource\fR \fItarget_file\fR
23 \fB/usr/bin/mv\fR [\fB-fi\fR] \fIsource\fR... \fItarget_dir\fR
29 In the first synopsis form, the \fBmv\fR utility moves the file named by the
30 \fIsource\fR operand to the destination specified by the \fItarget_file\fR.
31 \fIsource\fR and \fItarget_file\fR can not have the same name. If
32 \fItarget_file\fR does not exist, \fBmv\fR creates a file named
33 \fItarget_file\fR. If \fItarget_file\fR exists, its contents are overwritten.
34 This first synopsis form is assumed when the final operand does not name an
38 In the second synopsis form, \fBmv\fR moves each file named by a \fIsource\fR
39 operand to a destination file in the existing directory named by the
40 \fItarget_dir\fR operand. The destination path for each \fIsource\fR is the
41 concatenation of the target directory, a single slash character (\fB/\fR), and
42 the last path name component of the \fIsource\fR. This second form is assumed
43 when the final operand names an existing directory.
46 If \fBmv\fR determines that the mode of \fItarget_file\fR forbids writing, it
47 prints the mode (see \fBchmod\fR(2)), ask for a response, and read the standard
48 input for one line. If the response is affirmative, the \fBmv\fR occurs, if
49 permissible; otherwise, the command exits. Notice that the mode displayed can
50 not fully represent the access permission if \fItarget\fR is associated with an
51 \fBACL\fR. When the parent directory of \fIsource\fR is writable and has the
52 sticky bit set, one or more of the following conditions must be true:
57 the user must own the file
63 the user must own the directory
69 the file must be writable by the user
75 the user must be a privileged user
79 If \fIsource\fR is a file and \fItarget_file\fR is a link to another file with
80 links, the other links remain and \fItarget_file\fR becomes a new file.
83 If \fIsource\fR and \fItarget_file\fR/\fItarget_dir\fR are on different file
84 systems, \fBmv\fR copies the source and deletes the original. Any hard links to
85 other files are lost. \fBmv\fR attempts to duplicate the source file
86 characteristics to the target, that is, the owner and group id, permission
87 modes, modification and access times, \fBACL\fRs, and extended attributes, if
88 applicable. For symbolic links, \fBmv\fR preserves only the owner and group of
92 If unable to preserve owner and group id, \fBmv\fR clears \fBS_ISUID\fR and
93 \fBS_ISGID\fR bits in the target. \fBmv\fR prints a diagnostic message to
94 stderr if unable to clear these bits, though the exit code is not affected.
95 \fBmv\fR might be unable to preserve extended attributes if the target file
96 system does not have extended attribute support. \fBmv\fR prints
97 a diagnostic message to stderr for all other failed attempts to duplicate file
98 characteristics. The exit code is not affected.
101 In order to preserve the source file characteristics, users must have the
102 appropriate file access permissions. This includes being super-user or having
103 the same owner id as the destination file.
107 The following options are supported:
114 \fBmv\fR moves the file(s) without prompting even if it is writing over an
115 existing \fItarget\fR. Note that this is the default if the standard input is
125 \fBmv\fR prompts for confirmation whenever the move would overwrite an existing
126 \fItarget\fR. An affirmative answer means that the move should proceed. Any
127 other answer prevents \fBmv\fR from overwriting the \fItarget\fR.
132 Specifying both the \fB-f\fR and the \fB-i\fR options is not considered an
133 error. The last option specified determines the behavior of \fBmv\fR.
137 The following operands are supported:
144 A path name of a file or directory to be moved.
150 \fB\fItarget_file\fR\fR
153 A new path name for the file or directory being moved.
159 \fB\fItarget_dir\fR\fR
162 A path name of an existing directory into which to move the input files.
168 See \fBlargefile\fR(5) for the description of the behavior of \fBmv\fR when
169 encountering files greater than or equal to 2 Gbyte ( 2^31 bytes).
170 .SH ENVIRONMENT VARIABLES
173 See \fBenviron\fR(5) for descriptions of the following environment variables
174 that affect the execution of \fBmv\fR: \fBLANG\fR, \fBLC_ALL\fR,
175 \fBLC_COLLATE\fR, \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR.
178 Affirmative responses are processed using the extended regular expression
179 defined for the \fByesexpr\fR keyword in the \fBLC_MESSAGES\fR category of the
180 user's locale. The locale specified in the \fBLC_COLLATE\fR category defines
181 the behavior of ranges, equivalence classes, and multi-character collating
182 elements used in the expression defined for \fByesexpr\fR. The locale specified
183 in \fBLC_CTYPE\fR determines the locale for interpretation of sequences of
184 bytes of text data a characters, the behavior of character classes used in the
185 expression defined for the \fByesexpr\fR. See \fBlocale\fR(5).
189 The following exit values are returned:
196 All input files were moved successfully.
211 See \fBattributes\fR(5) for descriptions of the following attributes:
220 ATTRIBUTE TYPE ATTRIBUTE VALUE
224 Interface Stability Standard
230 \fBcp\fR(1), \fBcpio\fR(1), \fBln\fR(1), \fBrm\fR(1), \fBsetfacl\fR(1),
231 \fBchmod\fR(2), \fBattributes\fR(5), \fBenviron\fR(5), \fBfsattr\fR(5),
232 \fBlargefile\fR(5), \fBstandards\fR(5)
236 A \fB--\fR permits the user to mark explicitly the end of any command line
237 options, allowing \fBmv\fR to recognize filename arguments that begin with a
238 \fB-\fR. As an aid to BSD migration, \fBmv\fR accepts \fB-\fR as a synonym for
239 \fB--\fR. This migration aid might disappear in a future release.