mv
mv [OPTION]... [-T] SOURCE DEST
mv [OPTION]... SOURCE... DIRECTORY
mv [OPTION]... -t DIRECTORY SOURCE...
Move SOURCE
to DEST
, or multiple SOURCE
(s) to DIRECTORY
.
Options
--force
,-f
-
do not prompt before overwriting
--interactive
,-i
-
prompt before override
--no-clobber
,-n
-
do not overwrite an existing file
--strip-trailing-slashes
-
remove any trailing slashes from each SOURCE argument
--backup=<CONTROL>
-
make a backup of each existing destination file
-b
-
like --backup but does not accept an argument
--suffix=<SUFFIX>
,-S <SUFFIX>
-
override the usual backup suffix
--update
-
move only when the SOURCE file is newer than the destination file or when the destination file is missing
-u
-
like --update but does not accept an argument
--target-directory=<DIRECTORY>
,-t <DIRECTORY>
-
move all SOURCE arguments into DIRECTORY
--no-target-directory
,-T
-
treat DEST as a normal file
--verbose
,-v
-
explain what is being done
--progress
,-g
-
Display a progress bar.
Note: this feature is not supported by GNU coreutils. --debug
-
explain how a file is copied. Implies -v
When specifying more than one of -i, -f, -n, only the final one will take effect.
Do not move a non-directory that has an existing destination with the same or newer modification timestamp;
instead, silently skip the file without failing. If the move is across file system boundaries, the comparison is
to the source timestamp truncated to the resolutions of the destination file system and of the system calls used
to update timestamps; this avoids duplicate work if several mv -u
commands are executed with the same source
and destination. This option is ignored if the -n
or --no-clobber
option is also specified. which gives more control
over which existing files in the destination are replaced, and its value can be one of the following:
all
This is the default operation when an--update
option is not specified, and results in all existing files in the destination being replaced.none
This is similar to the--no-clobber
option, in that no files in the destination are replaced, but also skipping a file does not induce a failure.older
This is the default operation when--update
is specified, and results in files being replaced if they’re older than the corresponding source file.
Examples
Rename a file or directory when the target is not an existing directory:
mv {{path/to/source}} {{path/to/target}}
Move a file or directory into an existing directory:
mv {{path/to/source}} {{path/to/existing_directory}}
Move multiple files into an existing directory, keeping the filenames unchanged:
mv {{path/to/source1 path/to/source2 ...}} {{path/to/existing_directory}}
Do not prompt ([f]) for confirmation before overwriting existing files:
mv --force {{path/to/source}} {{path/to/target}}
Prompt for confirmation [i]nteractively before overwriting existing files, regardless of file permissions:
mv --interactive {{path/to/source}} {{path/to/target}}
Do not overwrite ([n]) existing files at the target:
mv --no-clobber {{path/to/source}} {{path/to/target}}
Move files in [v]erbose mode, showing files after they are moved:
mv --verbose {{path/to/source}} {{path/to/target}}
Specify [t]arget directory so that you can use external tools to gather movable files:
{{find /var/log -type f -name '*.log' -print0}} | {{xargs -0}} mv --target-directory {{path/to/target_directory}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.