Do not use .Xo/.Xc to work around ancient roff limits.
[netbsd-mini2440.git] / bin / mv / mv.1
blob2350888693023653c40734022cca1a1246fa654d
1 .\"     $NetBSD: mv.1,v 1.24 2003/08/07 09:05:18 agc Exp $
2 .\"
3 .\" Copyright (c) 1989, 1990, 1993
4 .\"     The Regents of the University of California.  All rights reserved.
5 .\"
6 .\" This code is derived from software contributed to Berkeley by
7 .\" the Institute of Electrical and Electronics Engineers, Inc.
8 .\"
9 .\" Redistribution and use in source and binary forms, with or without
10 .\" modification, are permitted provided that the following conditions
11 .\" are met:
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\"    notice, this list of conditions and the following disclaimer.
14 .\" 2. Redistributions in binary form must reproduce the above copyright
15 .\"    notice, this list of conditions and the following disclaimer in the
16 .\"    documentation and/or other materials provided with the distribution.
17 .\" 3. Neither the name of the University nor the names of its contributors
18 .\"    may be used to endorse or promote products derived from this software
19 .\"    without specific prior written permission.
20 .\"
21 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 .\" SUCH DAMAGE.
32 .\"
33 .\"     @(#)mv.1        8.1 (Berkeley) 5/31/93
34 .\"
35 .Dd December 26, 2002
36 .Dt MV 1
37 .Os
38 .Sh NAME
39 .Nm mv
40 .Nd move files
41 .Sh SYNOPSIS
42 .Nm
43 .Op Fl fiv
44 .Ar source target
45 .Nm
46 .Op Fl fiv
47 .Ar source ... directory
48 .Sh DESCRIPTION
49 In its first form, the
50 .Nm
51 utility renames the file named by the
52 .Ar source
53 operand to the destination path named by the
54 .Ar target
55 operand.
56 This form is assumed when the last operand does not name an already
57 existing directory.
58 .Pp
59 In its second form,
60 .Nm
61 moves each file named by a
62 .Ar source
63 operand to a destination file in the existing directory named by the
64 .Ar directory
65 operand.
66 The destination path for each operand is the pathname produced by the
67 concatenation of the last operand, a slash, and the final pathname
68 component of the named file.
69 .Pp
70 The following options are available:
71 .Bl -tag -width flag
72 .It Fl f
73 Do not prompt for confirmation before overwriting the destination
74 path.
75 .It Fl i
76 Causes
77 .Nm
78 to write a prompt to standard error before moving a file that would
79 overwrite an existing file.
80 If the response from the standard input begins with the character ``y'',
81 the move is attempted.
82 .It Fl v
83 Cause
84 .Nm
85 to be verbose, showing files as they are processed.
86 .El
87 .Pp
88 The last of any
89 .Fl f
91 .Fl i
92 options is the one which affects
93 .Nm Ns 's
94 behavior.
95 .Pp
96 It is an error for any of the
97 .Ar source
98 operands to specify a nonexistent file or directory.
99 .Pp
100 It is an error for the
101 .Ar source
102 operand to specify a directory if the
103 .Ar target
104 exists and is not a directory.
106 If the destination path does not have a mode which permits writing,
108 prompts the user for confirmation as specified for the
109 .Fl i
110 option.
112 Should the
113 .Xr rename  2
114 call fail because
115 .Ar source
117 .Ar target
118 are on different file systems,
120 will remove the destination file, copy the source file to the
121 destination, and then remove the source.
122 The effect is roughly equivalent to:
123 .Bd -literal -offset indent
124 rm -f destination_path \*[Am]\*[Am] \e
125 cp -PRp source_file destination_path \*[Am]\*[Am] \e
126 rm -rf source_file
128 .Sh EXIT STATUS
131 utility exits 0 on success, and \*[Gt]0 if an error occurs.
132 .Sh SEE ALSO
133 .Xr cp 1 ,
134 .Xr rename 2 ,
135 .Xr symlink 7
136 .Sh STANDARDS
139 utility is expected to be
140 .St -p1003.2
141 compatible.
144 .Fl v
145 option is an extension to
146 .St -p1003.2 .