xref: /original-bsd/bin/mv/mv.1 (revision 1344f446)
1.\" Copyright (c) 1989, 1990 The Regents of the University of California.
2.\" 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.\" %sccs.include.redist.roff%
8.\"
9.\"	@(#)mv.1	6.9 (Berkeley) 07/27/91
10.\"
11.Dd
12.Dt MV 1
13.Os
14.Sh NAME
15.Nm mv
16.Nd move files
17.Sh SYNOPSIS
18.Nm mv
19.Op Fl f | Fl i
20.Ar source target
21.Nm mv
22.Op  Fl f | Fl i
23.Ar source ... source directory
24.Sh DESCRIPTION
25.Pp
26In its first form, the
27.Nm mv
28utility renames the file named by the
29.Ar source
30operand to the destination path named by the
31.Ar target
32operand.
33This form is assumed when the last operand does not name an already
34existing directory.
35.Pp
36In its second form,
37.Nm mv
38moves each file named by a
39.Ar source
40operand to a destination file in the existing directory named by the
41.Ar directory
42operand.
43The destination path for each operand is the pathname produced by the
44concatenation of the last operand, a slash, and the final pathname
45component of the named file.
46.Pp
47The following options are available:
48.Bl -tag -width flag
49.It Fl f
50Do not prompt for confirmation before overwriting the destination
51path.
52(The
53.Fl i
54option is ignored if the
55.Fl f
56option is specified.)
57.It Fl i
58Causes
59.Nm mv
60to write a prompt to standard error before moving a file that would
61overwrite an existing file.
62If the response from the standard input begins with the character ``y'',
63the move is attempted.
64.El
65.Pp
66It is an error for either the
67.Ar source
68operand or the destination path to specify a directory unless both do.
69.Pp
70If the destination path does not have a mode which permits writing,
71.Nm mv
72prompts the user for confirmation as specified for the
73.Fl i
74option.
75.Pp
76As the
77.Xr rename  2
78call does not work across file systems,
79.Nm mv
80uses
81.Xr cp 1
82and
83.Xr rm 1
84to accomplish the move.
85The effect is equivalent to:
86.Bd -literal -offset indent
87rm -f destination_path && \e
88\tcp -pr source_file destination && \e
89\trm -rf source_file
90.Ed
91.Pp
92The
93.Nm mv
94utility exits 0 on success, and >0 if an error occurs.
95.Sh SEE ALSO
96.Xr cp 1
97.Sh STANDARDS
98The
99.Nm mv
100utility is expected to be
101.St -p1003.2
102compatible.
103