xref: /openbsd/bin/mv/mv.1 (revision 93256fbc)
1.\"	$OpenBSD: mv.1,v 1.11 2000/10/18 06:55:09 aaron Exp $
2.\"	$NetBSD: mv.1,v 1.8 1995/03/21 09:06:51 cgd Exp $
3.\"
4.\" Copyright (c) 1989, 1990, 1993
5.\"	The Regents of the University of California.  All rights reserved.
6.\"
7.\" This code is derived from software contributed to Berkeley by
8.\" the Institute of Electrical and Electronics Engineers, Inc.
9.\"
10.\" Redistribution and use in source and binary forms, with or without
11.\" modification, are permitted provided that the following conditions
12.\" are met:
13.\" 1. Redistributions of source code must retain the above copyright
14.\"    notice, this list of conditions and the following disclaimer.
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\"    notice, this list of conditions and the following disclaimer in the
17.\"    documentation and/or other materials provided with the distribution.
18.\" 3. All advertising materials mentioning features or use of this software
19.\"    must display the following acknowledgement:
20.\"	This product includes software developed by the University of
21.\"	California, Berkeley and its contributors.
22.\" 4. Neither the name of the University nor the names of its contributors
23.\"    may be used to endorse or promote products derived from this software
24.\"    without specific prior written permission.
25.\"
26.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36.\" SUCH DAMAGE.
37.\"
38.\"	@(#)mv.1	8.1 (Berkeley) 5/31/93
39.\"
40.Dd May 31, 1993
41.Dt MV 1
42.Os
43.Sh NAME
44.Nm mv
45.Nd move files
46.Sh SYNOPSIS
47.Nm mv
48.Op Fl fi
49.Ar source target
50.Nm mv
51.Op Fl fi
52.Ar source ... directory
53.Sh DESCRIPTION
54In its first form, the
55.Nm
56utility renames the file named by the
57.Ar source
58operand to the destination path named by the
59.Ar target
60operand.
61This form is assumed when the last operand does not name an already
62existing directory.
63.Pp
64In its second form,
65.Nm
66moves each file named by a
67.Ar source
68operand to a destination file in the existing directory named by the
69.Ar directory
70operand.
71The destination path for each operand is the pathname produced by the
72concatenation of the last operand, a slash, and the final pathname
73component of the named file.
74.Pp
75The options are as follows:
76.Bl -tag -width flag
77.It Fl f
78Do not prompt for confirmation before overwriting the destination
79path.
80.It Fl i
81Causes
82.Nm
83to write a prompt to standard error before moving a file that would
84overwrite an existing file.
85If the response from the standard input begins with the character
86.Dq y ,
87the move is attempted.
88.El
89.Pp
90The last of any
91.Fl f
92or
93.Fl i
94options is the one which affects
95.Nm mv Ns 's
96behavior.
97.Pp
98It is an error for either the
99.Ar source
100operand or the destination path to specify a directory unless both do.
101.Pp
102If the destination path does not have a mode which permits writing,
103.Nm
104prompts the user for confirmation as specified for the
105.Fl i
106option.
107.Pp
108As the
109.Xr rename 2
110call does not work across file systems,
111.Nm
112uses
113.Xr cp 1
114and
115.Xr rm 1
116to accomplish the move.
117The effect is equivalent to:
118.Bd -literal -offset indent
119rm -f destination_path && \e
120\tcp -pr source_file destination && \e
121\trm -rf source_file
122.Ed
123.Pp
124The
125.Nm
126utility exits 0 on success or >0 if an error occurred.
127.Sh EXAMPLES
128.Cm mv -f foo bar
129.Pp
130Rename file
131.Pa foo
132to
133.Pa bar ,
134overwriting
135.Pa bar
136if it already exists.
137.Sh SEE ALSO
138.Xr cp 1 ,
139.Xr symlink 7
140.Sh STANDARDS
141The
142.Nm
143utility is expected to be
144.St -p1003.2
145compatible.
146.Sh HISTORY
147A
148.Nm
149command appeared in
150.At v1 .
151