xref: /minix/bin/mv/mv.1 (revision c38c77c1)
1.\"	$NetBSD: mv.1,v 1.28 2016/08/10 18:08:14 sevan 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 August 10, 2016
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
49In its first form, the
50.Nm
51utility renames the file named by the
52.Ar source
53operand to the destination path named by the
54.Ar target
55operand.
56This form is assumed when the last operand does not name an already
57existing directory.
58.Pp
59In its second form,
60.Nm
61moves each file named by a
62.Ar source
63operand to a destination file in the existing directory named by the
64.Ar directory
65operand.
66The destination path for each operand is the pathname produced by the
67concatenation of the last operand, a slash, and the final pathname
68component of the named file.
69.Pp
70The following options are available:
71.Bl -tag -width flag
72.It Fl f
73Do not prompt for confirmation before overwriting the destination
74path.
75.It Fl i
76Causes
77.Nm
78to write a prompt to standard error before moving a file that would
79overwrite an existing file.
80If the response from the standard input begins with the character ``y'',
81the move is attempted.
82.It Fl v
83Cause
84.Nm
85to be verbose, showing files as they are processed.
86.El
87.Pp
88The last of any
89.Fl f
90or
91.Fl i
92options is the one which affects
93.Nm Ns 's
94behavior.
95.Pp
96It is an error for any of the
97.Ar source
98operands to specify a nonexistent file or directory.
99.Pp
100It is an error for the
101.Ar source
102operand to specify a directory if the
103.Ar target
104exists and is not a directory.
105.Pp
106If the destination path does not have a mode which permits writing,
107.Nm
108prompts the user for confirmation as specified for the
109.Fl i
110option.
111.Pp
112Should the
113.Xr rename 2
114call fail because
115.Ar source
116and
117.Ar target
118are on different file systems,
119.Nm
120will remove the destination file, copy the source file to the
121destination, and then remove the source.
122The effect is roughly equivalent to:
123.Bd -literal -offset indent
124rm -f destination_path \*[Am]\*[Am] \e
125cp -PRp source_file destination_path \*[Am]\*[Am] \e
126rm -rf source_file
127.Ed
128.Sh EXIT STATUS
129The
130.Nm
131utility 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
137The
138.Nm
139utility is expected to be
140.St -p1003.2
141compatible.
142.Pp
143The
144.Fl v
145option is an extension to
146.St -p1003.2 .
147.Sh HISTORY
148An
149.Nm
150utility appeared in
151.At v1 .
152