Move files (POSIX)
mv [-f|-i] [-v|-V] source_file target_file mv [-f|-i] [-v|-V] source_file... target_dir
QNX Neutrino, Microsoft Windows
The mv command has two syntax forms:
mv dir/dir/myfile /existingdirmoves dir/dir/myfile to existingdir/myfile.
This second syntax form is assumed when either the destination names an existing directory, or when more than one source file is specified.
|By default, mv overwrites an existing file without warning or confirmation whenever you have write permission on the file.|
The mv utility asks you for confirmation if the following conditions are met:
Upon receiving confirmation, mv overwrites the target file. It can do this only if you own the file or you're a superuser.
If you want mv to request confirmation before overwriting any file, specify the -i (interactive) option. If you want mv to overwrite whenever possible without asking for confirmation, specify the -f (force) option.
As long as the input files specified by each source_file are on the same device as the target, the source_file operand can be of any file type. If the source and target reside on different devices, the source_file is copied to the target and then removed. If the source_file is a directory, this means that any FIFO or character special files under the original directory aren't copied. Since the copy isn't 100% successful, the original source_file isn't removed.
In the current directory, rename the file orange to banana.
mv orange banana
If the copying of a directory is prematurely terminated by a signal or error, mv may leave a partial copy of the directory at the destination. In this case, the directory tree at source_file isn't modified.
When the source_file and target_file are on different filesystems (i.e. not on the same mounted partition), the mv utility spawns the cp utility to copy the file(s), and if the cp succeeds, spawns the rm utility to remove the originals.
cp, pax, rm