mv(C)


mv -- move or rename files and directories

Syntax

mv [ -fi ] source_file target_file

mv [ -fi ] source_file

mv [ -1 ] source_dir target_dir ... target_directory

Description

In the first form, the mv command moves (changes the name of) source_file to target_file. This form is assumed when target_file does not name a directory.

If the destination file already exists, it is removed before source_file is copied. If the permissions of the destination file do not permit writing and the standard input is a terminal, or the -i option was specified, mv prints the destination pathname and the mode (see chmod(S)) and prompts for confirmation. If you type ``y'', the move takes place; otherwise mv does not move the file and continues to the next source_file.

In the second form, mv moves each source_file to a new destination directory. The destination path is formed for each file by concatenating the target_directory, a slash, and the basename of the source_file.

The -f option suppresses all prompting.

The third form operates on directories. If the -1 option is used, the source_dir replaces the target_dir (unless the target_dir is not empty). Without the -1 option, the source_dir becomes a subdirectory of the target_dir.

mv attempts to preserve the following characteristics of each file moved:

mv can move directories, even across filesystems.

Examples

To move /tmp/temporary.file to newfile:

mv /tmp/temporary.file newfile

To move all the files in /tmp to the current directory:

mv /tmp/*  .

To force mv to overwrite thisfile with /tmp/thisfile (when moving /tmp/thisfile to the current directory):

mv -f /tmp/thisfile thisfile

Limitations

If mv has to copy a file across filesystems it may not be possible to preserve all the above characteristics. mv does not follow symbolic links given as arguments.

mv refuses to move a file onto itself.

See also

chmod(S), copy(C), cp(C), ln(C)

Standards conformance

mv is conformant with:

ISO/IEC DIS 9945-2:1992, Information technology - Portable Operating System Interface (POSIX) - Part 2: Shell and Utilities (IEEE Std 1003.2-1992);
AT&T SVID Issue 2;
X/Open CAE Specification, Commands and Utilities, Issue 4, 1992.

Notices

A version of mv that can handle files greater than 2GB is available in /u95/bin. See mv(1) for more information.
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 03 June 2005