mirror of https://github.com/mkerrisk/man-pages
170 lines
4.9 KiB
Groff
170 lines
4.9 KiB
Groff
.\" Copyright Andries Brouwer, Ragnar Hojland Espinosa and A. Wik, 1998.
|
|
.\"
|
|
.\" This file may be copied under the conditions described
|
|
.\" in the LDP GENERAL PUBLIC LICENSE, Version 1, September 1998
|
|
.\" that should have been distributed together with this file.
|
|
.\"
|
|
.TH MV 1 1998-11 "GNU fileutils 4.0"
|
|
.SH NAME
|
|
mv \- move (rename) files
|
|
.SH SYNOPSIS
|
|
.BI "mv [" "option..." "] " "source target"
|
|
.br
|
|
.BI "mv [" "option..." "] " "source... target"
|
|
.sp
|
|
POSIX options:
|
|
.B "[\-fi] [\-\-]"
|
|
.sp
|
|
GNU options (shortest form):
|
|
.BI "[\-bfiuv] [\-S " suffix "] [\-V {numbered,existing,simple}] "
|
|
.B "[\-\-help] [\-\-version] [\-\-]"
|
|
.SH DESCRIPTION
|
|
.B mv
|
|
moves or renames files or directories.
|
|
.PP
|
|
If the last argument names an existing directory,
|
|
.B mv
|
|
moves each other given file into a file with the same name in that
|
|
directory. Otherwise, if only two files are given, it renames the
|
|
first as the second. It is an error if the last argument is not a
|
|
directory and more than two files are given.
|
|
.PP
|
|
Thus, `mv /a/x/y /b' will rename the file /a/x/y into /b/y if /b
|
|
was an existing directory, and into /b otherwise.
|
|
.PP
|
|
Let us call the file a given file is going to be moved into its
|
|
.IR destination .
|
|
If
|
|
.I destination
|
|
exists, and either the \-i option is given, or
|
|
.I destination
|
|
is unwritable, standard input is a terminal, and the
|
|
.B "\-f"
|
|
option is not given,
|
|
.B mv
|
|
prompts the user for whether to replace the file, writing a question
|
|
to stderr and reading an answer from stdin. If the response
|
|
is not affirmative, the file is skipped.
|
|
.PP
|
|
When both
|
|
.I source
|
|
and
|
|
.I destination
|
|
are on the same filesystem, they are the same file (just the name is
|
|
changed; owner, mode, timestamps remain unchanged).
|
|
When they are on different filesystems, the source file is copied
|
|
and then deleted.
|
|
.B mv
|
|
will copy modification time, access time, user and group ID, and mode
|
|
if possible.
|
|
When copying user and/or group ID fails, the set-user-ID and
|
|
set-group-ID bits are cleared in the copy.
|
|
.SH "POSIX OPTIONS"
|
|
.TP
|
|
.B "\-f"
|
|
Do not prompt for confirmation.
|
|
.TP
|
|
.B "\-i"
|
|
Prompt for confirmation when
|
|
.I destination
|
|
exists.
|
|
(In case both \-f and \-i are given, the last one given takes effect.)
|
|
.TP
|
|
.B "\-\-"
|
|
Terminate option list.
|
|
.SH "GNU DETAILS"
|
|
The GNU implementation (in fileutils-3.16) is broken in the sense that
|
|
.B mv
|
|
can move only regular files across filesystems.
|
|
.SH "GNU OPTIONS"
|
|
.TP
|
|
.B "\-f, \-\-force"
|
|
Remove existing destination files and never prompt the user.
|
|
.TP
|
|
.B "\-i, \-\-interactive"
|
|
Prompt whether to overwrite existing regular destination files.
|
|
If the response is not affirmative, the file is skipped.
|
|
.TP
|
|
.B "\-u, \-\-update"
|
|
Do not move a nondirectory that has an existing destination with
|
|
the same or newer modification time.
|
|
.TP
|
|
.B "\-v, \-\-verbose"
|
|
Print the name of each file before moving it.
|
|
.SH "GNU BACKUP OPTIONS"
|
|
The GNU versions of programs like
|
|
.BR cp ,
|
|
.BR mv ,
|
|
.BR ln ,
|
|
.B install
|
|
and
|
|
.B patch
|
|
will make a backup of files about to be overwritten, changed or destroyed
|
|
if that is desired. That backup files are desired is indicated by
|
|
the \-b option. How they should be named is specified by the \-V option.
|
|
In case the name of the backup file is given by the name of the file
|
|
extended by a suffix, this suffix is specified by the \-S option.
|
|
.TP
|
|
.B "\-b, \-\-backup"
|
|
Make backups of files that are about to be overwritten or removed.
|
|
.TP
|
|
.BI "\-S " SUFFIX ", \-\-suffix=" SUFFIX
|
|
Append
|
|
.I SUFFIX
|
|
to each backup file made.
|
|
If this option is not specified, the value of the
|
|
.B SIMPLE_BACKUP_SUFFIX
|
|
environment variable is used. And if
|
|
.B SIMPLE_BACKUP_SUFFIX
|
|
is not set, the default is `~'.
|
|
.TP
|
|
.BI "\-V " METHOD ", \-\-version\-control=" METHOD
|
|
.RS
|
|
Specify how backup files are named. The
|
|
.I METHOD
|
|
argument can be `numbered' (or `t'), `existing' (or `nil'), or `never' (or
|
|
`simple').
|
|
If this option is not specified, the value of the
|
|
.B VERSION_CONTROL
|
|
environment variable is used. And if
|
|
.B VERSION_CONTROL
|
|
is not set, the default backup type is `existing'.
|
|
.PP
|
|
This option corresponds to the Emacs variable `version-control'.
|
|
The valid
|
|
.IR METHOD s
|
|
are (unique abbreviations are accepted):
|
|
.TP
|
|
.BR t ", " numbered
|
|
Always make numbered backups.
|
|
.TP
|
|
.BR nil ", " existing
|
|
Make numbered backups of files that already have them, simple
|
|
backups of the others.
|
|
.TP
|
|
.BR never ", " simple
|
|
Always make simple backups.
|
|
.RE
|
|
.SH "GNU STANDARD OPTIONS"
|
|
.TP
|
|
.B "\-\-help"
|
|
Print a usage message on standard output and exit successfully.
|
|
.TP
|
|
.B "\-\-version"
|
|
Print version information on standard output, then exit successfully.
|
|
.TP
|
|
.B "\-\-"
|
|
Terminate option list.
|
|
.SH ENVIRONMENT
|
|
The variables LANG, LC_ALL, LC_COLLATE, LC_CTYPE and LC_MESSAGES have the
|
|
usual meaning. For the GNU version, the variables SIMPLE_BACKUP_SUFFIX
|
|
and VERSION_CONTROL control backup file naming, as described above.
|
|
.SH "CONFORMING TO"
|
|
POSIX.2, except that directory hierarchies cannot be moved
|
|
across filesystems.
|
|
.SH NOTES
|
|
This page describes
|
|
.B mv
|
|
as found in the fileutils-4.0 package;
|
|
other versions may differ slightly.
|