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