Merge branch 'vendor/GCC50'
[dragonfly.git] / bin / mv / mv.1
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
50 In its first form, the
51 .Nm
52 utility renames the file named by the
53 .Ar source
54 operand to the destination path named by the
55 .Ar target
56 operand.
57 This form is assumed when the last operand does not name an already
58 existing directory.
59 .Pp
60 In its second form,
61 .Nm
62 moves each file named by a
63 .Ar source
64 operand to a destination file in the existing directory named by the
65 .Ar directory
66 operand.
67 The destination path for each operand is the pathname produced by the
68 concatenation of the last operand, a slash, and the final pathname
69 component of the named file.
70 .Pp
71 The following options are available:
72 .Bl -tag -width indent
73 .It Fl f
74 Do not prompt for confirmation before overwriting the destination
75 path.
76 (The
77 .Fl f
78 option overrides any previous
79 .Fl i
80 or
81 .Fl n
82 options.)
83 .It Fl h
84 If the
85 .Ar target
86 operand is a symbolic link to a directory,
87 do not follow it.
88 This causes the
89 .Nm
90 utility to rename the file
91 .Ar source
92 to the destination path
93 .Ar target
94 rather than moving
95 .Ar source
96 into the directory referenced by
97 .Ar target .
98 .It Fl i
99 Cause
100 .Nm
101 to write a prompt to standard error before moving a file that would
102 overwrite an existing file.
103 If the response from the standard input begins with the character
104 .Ql y
105 or
106 .Ql Y ,
107 the move is attempted.
108 (The
109 .Fl i
110 option overrides any previous
111 .Fl f
112 or
113 .Fl n
114 options.)
115 .It Fl n
116 Do not overwrite an existing file.
117 (The
118 .Fl n
119 option overrides any previous
120 .Fl f
121 or
122 .Fl i
123 options.)
124 .It Fl v
125 Cause
126 .Nm
127 to be verbose, showing files after they are moved.
128 .El
129 .Pp
130 It is an error for the
131 .Ar source
132 operand to specify a directory if the target exists and is not a directory.
133 .Pp
134 If the destination path does not have a mode which permits writing,
135 .Nm
136 prompts the user for confirmation as specified for the
137 .Fl i
138 option.
139 .Pp
140 As the
141 .Xr rename 2
142 call does not work across file systems,
143 .Nm
144 uses
145 .Xr cp 1
146 and
147 .Xr rm 1
148 to accomplish the move.
149 The effect is equivalent to:
150 .Bd -literal -offset indent
151 rm -f destination_path && \e
152 cp -pRP source_file destination && \e
153 rm -rf source_file
154 .Ed
155 .Pp
156 If
157 .Nm
158 receives a
159 .Dv SIGINFO
160 (see the
161 .Cm status
162 argument for
163 .Xr stty 1 )
164 signal, the current input and output file
165 will be written to standard error.
166 .Sh EXIT STATUS
167 .Ex -std
168 .Sh COMPATIBILITY
169 The
170 .Fl h ,
171 .Fl n ,
172 and
173 .Fl v
174 options 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
180 The
181 .Nm
182 utility is expected to be
183 .St -p1003.2
184 compatible.
185 .Sh HISTORY
186 A
187 .Nm
188 command appeared in
189 .At v1 .