mv(1) mv(1)
NAME
mv - move or rename files
SYNOPSIS
mv [option ...] file filenew Format 1
mv [option ...] file ...dir Format 2
mv [--] dir dirnew Format 3
DESCRIPTION
mv is used to change the name of a file, or to move a file from one
directory to another within the file tree. To be able to use mv you
have to have write permission for the directory in which the file
resides or the directory to which you want to move it, as appropriate.
mv does not make copies of files that are moved or renamed within the
same file system. Instead, it simply modifies the appropriate entries
in the parent directory, retaining any links to other files.
OPTIONS
Format 1: Renaming a file
mv [option ...] file filenew
The options -f and -i override each other. mv is determined by the
last specified option.
No option specified
If you specify an existing file for newfile and do not have write
permission for it, mv displays the mode of newfile and prompts
you to confirm whether it should proceed. It only does so if your
answer begins with y.
Caution:
If the standard input is not a terminal, no prompt for confirma-
tion is displayed and newfile will not be overwritten).
-f If a file named newfile already exists, mv will overwrite the
existing file even if you do not have write permission for it.
-i (interactive) If you specify an existing file for newfile, you
will always be asked to confirm whether mv should really proceed.
Page 1 Reliant UNIX 5.44 Printed 11/98
mv(1) mv(1)
When the Veritas File System (VxFS) is installed on the system, the
following additional option is available:
-e extentop
Specify how to process extent attribute information. This option
specifies the required persistence of extent attributes when pro-
cessing files which have preallocated space or fixed extent
sizes. Valid values for extentop are:
warn issue a warning message if extent attribute information
cannot be kept (the default behavior if this option is
not specified).
force fail the move if extent attribute information cannot be
kept.
ignore ignore extent attribute information.
-- If the name of a file to be renamed begins with a dash (-), the
end of the command-line options must be marked with --.
file Name of the file to be renamed.
newfile
New name for the file; must not be the same as file. If a file
named newfile already exists, it is overwritten by the contents
of file if you have write permission for newfile (also see -i).
If you specify an existing file for newfile and do not have write
permission for it, mv will display the mode of newfile and prompt
you to confirm whether it should proceed. The existing newfile is
not overwritten unless you answer y. If the -f option is speci-
fied, confirmation will not be requested and newfile will be
overwritten.
If the standard input is not a terminal, confirmation will not be
requested and newfile will not be overwritten
If the parent directory of newfile is writable but has the sticky
bit (the t bit) set, one or more of the following conditions must
be satisfied:
- the user must own the file
- the user must own the directory
- the user must have write permission for the file
- the user must be a privileged user
Page 2 Reliant UNIX 5.44 Printed 11/98
mv(1) mv(1)
Format 2: Moving files and directories to another directory
mv [options ...] file ... dir
The options -f und -i override each other. mv is determined by the
last specified option.
-f If a file with the name file already exists in dir, mv always
overwrites the file, whether you have write permission for the
existing file or not.
-i (i - interactive) If a file with the name file already exists in
dir, you will be asked whether you really want to execute mv.
-- If file begins with a dash, the end of the command-line options
must be marked with --.
file Names of files or directories to be moved to directory dir. If
you name a directory as source, all the files and directories
under it are moved recursively.
dir Name of the directory to which the files and/or directories are
to be moved. You need write permission for this target directory.
If dir is writable but has the t bit (sticky bit) set, one or
more of the following conditions must be satisfied:
- the user must own the file
- the user must own the target directory
- the user must have write permission for the file
- the user must be a privileged user
Format 3: Renaming a directory
mv [--] dir dirnew
-- If dir begins with a dash, the end of the command-line options
must be marked with --.
dir Name of the directory to be renamed.
newdir
New name for the directory.
dir and newdir do not necessarily belong to the same physical
file system; however, they do not have to share the same parent
directory.
Page 3 Reliant UNIX 5.44 Printed 11/98
mv(1) mv(1)
If a directory named newdir already exists, the directory named
dir is moved to the newdir directory (corresponding to Format 2).
ERROR MESSAGES
mv: cannot rename file
mv: permission denied
You do not have write permission for the directory to which file is to
be moved.
LOCALE
The LCMESSAGES environment variable governs the language in which
message texts are displayed. If LCMESSAGES is undefined or is defined
as the null string, it defaults to the value of LANG. If LANG is like-
wise undefined or null, the system acts as if it were not internation-
alized.
Answers to yes/no queries must be given in the language appropriate to
the current locale.
The LCALL environment variable governs the entire locale. LCALL
takes precedence over all the other environment variables which affect
internationalization.
EXAMPLES
Example 1
The file songs in the current working directory is to be renamed pop-
songs and moved to the directory /home/joanne/arts/music:
$ mv songs /home/joanne/arts/music/popsongs
Example 2
The files daisy, rose and violet in the current working directory are
to retain their names and be moved to the directory
/home/joanne/flowers:
$ mv daisy rose violet /home/joanne/flowers
SEE ALSO
chmod(1), cp(1), cpio(1), find(1), ln(1), rm(1).
Page 4 Reliant UNIX 5.44 Printed 11/98