Command format
CP [OPTION] ... [-T] SOURCE DEST
CP [OPTION] ... SOURCE... DIRECTORY
CP [OPTION] ...-t DIRECTORY SOURCE...
Command parameters
--backup[=control]
Create a backup of each existing target file.
-B
Similar to the--backup option, but does not accept parameters.
-F,--force
Do not prompt before overwriting.
-I.,--interactive
Give a hint before overwriting.
-N,--no-clobber
Does not overwrite existing files. If multiple in-I,-F,-n is specified, only the last one takes effect.
-S,--suffix=suffix
Replace the usual backup file suffix.
-T,--target-directory=directory
Moves the source file or directory specified by all parameters to the specified directory.
-T,--no-target-directory
Treat the target directory as a normal file.
-U,--update
When moving files from one directory to another, only those files that do not exist in the destination directory or the corresponding files in the destination directory are moved.
-V,--verbose
An informational message is displayed when the file is moved.
--help
Displays help information.
--version
Displays version information.
Instance
A) Move the file F1 to F2. If F2 exists, it will be overwritten by F1. If F2 does not exist, rename the F1 to F2.
MV F1 F2 [Email protected] cmdline]$ LSF2
b) Move the files F1 and F2 to the directory D1. D1 must already exist.
MV F1 F2 D1 [Email protected] cmdline]$ ls-r.:d 1./d1:f1 F2
c) Move the directory D1 and its contents to the directory D2. If D2 does not exist, it is equivalent to renaming D1 to D2.
[[email protected] cmdline]$ ls-lir.:total 4919434 drwxrwxr-x 2 ucm ucm 4096 Oct 1 14:33 d1./d1:total 49 19433 -rw-rw-r--1 UCM ucm 0 Oct 1 14:32 F1919432 -rw-rw-r--1 ucm ucm Oct mv D1 D2[ [Email protected] cmdline]$ ls-lir.:total 4919434 drwxrwxr-x 2 ucm ucm 4096 Oct 1 14:33 d2./d2:total 49 19433 -rw-rw-r--1 UCM ucm 0 Oct 1 14:32 F1919432 -rw-rw-r--1 ucm ucm Oct 1 14:32 f2
Linux Commands-MV: moving or renaming files