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