9103 opengroup acknowledgement should be properly formatted in man pages
[unleashed.git] / usr / src / man / man1 / mv.1
blob11faaa86f0e3550aa65222409b90acfe186910b5
1 .\"
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/.
6 .\"
7 .\" The Institute of Electrical and Electronics Engineers and The Open
8 .\" Group, have given us permission to reprint portions of their
9 .\" documentation.
10 .\"
11 .\" In the following statement, the phrase ``this text'' refers to portions
12 .\" of the system documentation.
13 .\"
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.
24 .\"
25 .\" This notice shall appear on any product containing this material.
26 .\"
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.
30 .\"
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.
35 .\"
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]
41 .\"
42 .\"
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
46 .\"
47 .TH MV 1 "Jul 17, 2007"
48 .SH NAME
49 mv \- move files
50 .SH SYNOPSIS
51 .LP
52 .nf
53 \fB/usr/bin/mv\fR [\fB-fi\fR] \fIsource\fR \fItarget_file\fR
54 .fi
56 .LP
57 .nf
58 \fB/usr/bin/mv\fR [\fB-fi\fR] \fIsource\fR... \fItarget_dir\fR
59 .fi
61 .LP
62 .nf
63 \fB/usr/xpg4/bin/mv\fR [\fB-fi\fR] \fIsource\fR \fItarget_file\fR
64 .fi
66 .LP
67 .nf
68 \fB/usr/xpg4/bin/mv\fR [\fB-fi\fR] \fIsource\fR... \fItarget_dir\fR
69 .fi
71 .SH DESCRIPTION
72 .sp
73 .LP
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
80 existing directory.
81 .sp
82 .LP
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.
89 .sp
90 .LP
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:
98 .RS +4
99 .TP
100 .ie t \(bu
101 .el o
102 the user must own the file
104 .RS +4
106 .ie t \(bu
107 .el o
108 the user must own the directory
110 .RS +4
112 .ie t \(bu
113 .el o
114 the file must be writable by the user
116 .RS +4
118 .ie t \(bu
119 .el o
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
134 the link itself.
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.
149 .SH OPTIONS
152 The following options are supported:
154 .ne 2
156 \fB\fB-f\fR\fR
158 .RS 6n
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
161 not a terminal.
165 .ne 2
167 \fB\fB-i\fR\fR
169 .RS 6n
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.
175 .SS "/usr/bin/mv"
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.
185 .SH OPERANDS
188 The following operands are supported:
190 .ne 2
192 \fB\fIsource\fR\fR
194 .RS 15n
195 A path name of a file or directory to be moved.
199 .ne 2
201 \fB\fItarget_file\fR\fR
203 .RS 15n
204 A new path name for the file or directory being moved.
208 .ne 2
210 \fB\fItarget_dir\fR\fR
212 .RS 15n
213 A path name of an existing directory into which to move the input files.
216 .SH USAGE
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).
237 .SH EXIT STATUS
240 The following exit values are returned:
242 .ne 2
244 \fB\fB0\fR\fR
246 .RS 6n
247 All input files were moved successfully.
251 .ne 2
253 \fB\fB>0\fR\fR
255 .RS 6n
256 An error occurred.
259 .SH ATTRIBUTES
262 See \fBattributes\fR(5) for descriptions of the following attributes:
263 .SS "/usr/bin/mv"
268 box;
269 c | c
270 l | l .
271 ATTRIBUTE TYPE  ATTRIBUTE VALUE
273 CSI     Enabled
275 Interface Stability     Stable
278 .SS "/usr/xpg4/bin/mv"
283 box;
284 c | c
285 l | l .
286 ATTRIBUTE TYPE  ATTRIBUTE VALUE
288 CSI     Enabled
290 Interface Stability     Standard
293 .SH SEE ALSO
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)
299 .SH NOTES
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.