mv

rename and move files and directories

Command


SYNOPSIS

mv [-dfiv] file1 file2

mv [-fiv] file ... directory

mv -r [-fiv] directory1 directory2


DESCRIPTION

mv renames files or moves them to a different directory. If you specify multiple files, the target (that is, the last path name on the command line) must be a directory. mv moves the files into that directory and gives them names that match the final components of the source path names. When you specify a single source file and the target is not a directory, mv moves the source to the new name, by a simple rename if possible.

If a destination file exists and you do not have write permission for it, mv prompts with the name of the existing file. If you answer y or yes, it deletes the destination and then moves the source.

Options

-d

delays moving the specified files until the system is rebooted.

This option relies upon the underlying operating system's capability to perform the action at reboot time.

-f

does not ask if you want to overwrite an existing destination without write permission; it automatically behaves as if you answered yes. If you specify both -f and -i, mv uses the option that appears last on the command line.

-i

always prompts before overwriting an existing file, whether or not the file is read-only. If you specify both -f and -i, mv uses the option that appears last on the command line.

-r

moves directory and all its contents (files, subdirectories, files in subdirectories, and so on). For example, mv -R dir1 dir2 moves the entire contents of dir1 to dir2/dir1. mv creates any directories that it needs.

-v

prints file names to standard output as they are being processed.


DIAGNOSTICS

Possible exit status values are:
0

Successful completion.

1

Failure due to any of the following:

— argument had trailing slash (/) but was not a directory
— file could not be found
— input file could not be opened for reading
— output file could not be created or opened for output
— read error occurred on an input file
— write error occurred on an output file
— input and output files were the same file
— input file could not be unlinked
— input file could not be renamed
— fatal error was encountered when using the -r option
Possible fatal -r errors include the following:
— inability to access a file
— inability to read a directory
— inability to remove a directory
— inability to create a directory
— a target that is not a directory
— the source and destination directories are the same
2

Failure due to any of the following:

— invalid command line option
— too few arguments on the command line
— a target that should be a directory but is not
— no space left on the target device
— out of memory to hold the data to be copied
— the inability to create a directory to hold a target file
cannot allocate target string

mv has no space to hold the name of the target file. Try to free up some memory to give mv more space.

filename read only?

You are attempting to move a file, but there is already a file with the target name and the file is read-only. If you really want to write over the existing file, type y and press ENTER. If you do not want to write over the existing file, type n and press ENTER.

source "name" and target "name" are identical

The source and the target are actually the same file (for example, because of links on UNIX and POSIX-compliant systems). In this case, mv does nothing.

unreadable directory "name"

mv cannot read the specified directory (for example, because you do not have appropriate permissions).


PORTABILITY

POSIX.2. x/OPEN Portability Guide 4.0.

The -d, -r, and -v options are extensions to the POSIX standard.


SEE ALSO

Commands:
cp, ln, rm


Updated MKS Toolkit [3khat16.ico]HP3000 [3khat16.ico]3kMail [archive16.gif]