NAME
mv — move
files
SYNOPSIS
mv |
[-fi] source_file
target_file |
mv |
[-fi] source_file...
target_file |
DESCRIPTION
In the first synopsis form, the mv utility
moves the file named by the source_file operand to the destination specified
by the target_file . This first synopsis form is assumed when the final
operand does not name an existing directory.
In the second synopsis form,
mv moves each file named by a
source_file operand to a destination
file in the existing directory named by the
target_dir
operand. The destination path for each
source_file is the concatenation of the target directory,
a single slash character, and the last pathname component of the
source_file.
This second form is assumed when the final operand names an existing
directory.
If any operand specifies an existing file of a type not specified by the XSH specification, the behaviour is implementation-dependent.
For each source_file the following steps are taken:
- If the destination path exists, the
-foption is not specified, and either of the following conditions is true: - The permissions of the destination path do not permit writing and the
standard input is a terminal.
The
-ioption is specified. - The
mvutility will write a prompt to standard error and read a line from standard input. If the response is not affirmative,mvwill do nothing more with the current source_file and go on to any remaining source_file s. - The
mvutility will perform actions equivalent to the XSH specification rename(3) function, called with the following arguments: - The source_file operand is used as the
old argument.
The destination path is used as the new argument.
- If this succeeds,
mvwill do nothing more with the current source_file and go on to any remaining source_file s. If this fails for any reasons other than those described for the errno [EXDEV] in the XSH specification,mvwill write a diagnostic message to standard error, do nothing more with the current source_file , and go on to any remaining source_file s. - If the destination path exists, and it is a file of type directory and
source_file is not a file of type directory, or it is a file not of type
directory and source_file is a file of type directory,
mvwill write a diagnostic message to standard error, do nothing more with the current source_file , and go on to any remaining source_file s. - If the destination path exists,
mvwill attempt to remove it. If this fails for any reason,mvwill write a diagnostic message to standard error, do nothing more with the current source_file, and go on to any remaining source_file s. - The file hierarchy rooted in source_file will be duplicated as a file hierarchy rooted in the destination path. The following characteristics of each file in the file hierarchy will be duplicated:
- the time of last data modification and time of last access
the user ID and group ID
the file mode.
- If the user ID, group ID or file mode of a regular file cannot be duplicated, the file mode bits S_ISUID and S_ISGID will not be duplicated.
- When files are duplicated to another file system, the implementation may
require that the process invoking
mvhas read access to each file being duplicated. - If the duplication of the file hierarchy fails for any reason,
mvwill write a diagnostic message to standard error, do nothing more with the current source_file, and go on to any remaining source_file s. - If the duplication of the file characteristics fails for any reason,
mvwill write a diagnostic message to standard error, but this failure will not causemvto modify its exit status. - The file hierarchy rooted in source_file will be removed. If this fails
for any reason,
mvwill write a diagnostic message to the standard error, do nothing more with the current source_file, and go on to any remaining source_file s.
OPTIONS
The mv utility supports the XBD
specification,
Utility
Syntax Guidelines .
The following options are supported:
- -f
- Do not prompt for confirmation if the destination path exists. Any
previous occurrences of the
-ioption will be ignored. - -i
- Prompt for confirmation if the destination path exists. Any previous
occurrences of the
-foption will be ignored.
Specifying more than one of the -f or
-i options is not considered an error. The last
option specified will determine the behaviour of
mv.
OPERANDS
The following operands are supported:
- source_file
- A pathname of a file or directory to be moved.
- target_file
- A new pathname for the file or directory being moved.
- target_dir
- A pathname of an existing directory into which to move the input files.
STDIN
Used to read an input line in response to each prompt specified in the STDERR section. Otherwise, the standard input will not be used.
INPUT FILES
The input files specified by each source_file operand can be of any file type.
ENVIRONMENT VARIABLES
The following environment variables affect the execution of
mv :
LANG- Provide a default value for the internationalisation variables that are
unset or null. If
LANGis unset or null, the corresponding value from the implementation-dependent default locale will be used. If any of the internationalisation variables contains an invalid setting, the utility will behave as if none of the variables had been defined. LC_ALL- If set to a non-empty string value, override the values of all the other internationalisation variables.
LC_COLLATE- Determine the locale for the behaviour of ranges, equivalence classes and multi-character collating elements used in the extended regular expression defined for the yesexpr locale keyword in the LC_MESSAGES category.
LC_CTYPE- Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single- as opposed to multi-byte characters in arguments and input files), the behaviour of character classes used in the extended regular expression defined for the yesexpr locale keyword in the LC_MESSAGES category.
LC_MESSAGES- Determine the locale for the processing of affirmative responses that should be used to affect the format and contents of diagnostic messages written to standard error.
NLSPATH- Determine the location of message catalogues for the processing of LC_MESSAGES .
ASYNCHRONOUS EVENTS
Default.
STDOUT
Not used.
STDERR
Prompts will be written to the standard error under the conditions specified in the DESCRIPTION section. The prompts will contain the destination pathname, but their format is otherwise unspecified. Otherwise, the standard error will be used only for diagnostic messages.
OUTPUT FILES
The output files may be of any file type.
EXTENDED DESCRIPTION
None.
EXIT STATUS
The following exit values are returned:
CONSEQUENCES OF ERRORS
If the copying or removal of source_file is prematurely terminated
by a signal or error, mv may leave a partial copy of
source_file at the source or destination. The mv
utility will not modify both source_file and the destination path
simultaneously; termination at any point will leave either source_file or
the destination path complete.
APPLICATION USAGE
None.
EXAMPLES
If the current directory contains only files a (of any type defined by the XSH specification), b (also of any type), and a directory c :
mv a b c mv c d
FUTURE DIRECTIONS
None.