cp
Options
- --target-directory=<target-directory>,- -t <target-directory>
- 
cp-help-target-directory 
- --no-target-directory,- -T
- 
cp-help-no-target-directory 
- --interactive,- -i
- 
cp-help-interactive 
- --link,- -l
- 
cp-help-link 
- --no-clobber,- -n
- 
cp-help-no-clobber 
- --recursive,- -R,- -r
- 
cp-help-recursive 
- --strip-trailing-slashes
- 
cp-help-strip-trailing-slashes 
- --debug
- 
cp-help-debug 
- --verbose,- -v
- 
cp-help-verbose 
- --symbolic-link,- -s
- 
cp-help-symbolic-link 
- --force,- -f
- 
cp-help-force 
- --remove-destination
- 
cp-help-remove-destination 
- --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 
- --reflink=<WHEN>
- 
cp-help-reflink 
- --attributes-only
- 
cp-help-attributes-only 
- --preserve=<ATTR_LIST>
- 
cp-help-preserve 
- --preserve-default-attributes,- -p
- 
cp-help-preserve-default 
- --no-preserve=<ATTR_LIST>
- 
cp-help-no-preserve 
- --parents
- 
cp-help-parents 
- --no-dereference,- -P
- 
cp-help-no-dereference 
- --dereference,- -L
- 
cp-help-dereference 
- -H
- 
cp-help-cli-symbolic-links 
- --archive,- -a
- 
cp-help-archive 
- -d
- 
cp-help-no-dereference-preserve-links 
- --one-file-system,- -x
- 
cp-help-one-file-system 
- --sparse=<WHEN>
- 
cp-help-sparse 
- -Z
- 
cp-help-selinux 
- --context=<CTX>
- 
cp-help-context 
- --progress,- -g
- 
cp-help-progress 
- --copy-contents
- 
cp-help-copy-contents 
Examples
Copy a file to another location:
cp {{path/to/source_file.ext}} {{path/to/target_file.ext}}
Copy a file into another directory, keeping the filename:
cp {{path/to/source_file.ext}} {{path/to/target_parent_directory}}
Recursively copy a directory's contents to another location (if the destination exists, the directory is copied inside it):
cp {{[-r|--recursive]}} {{path/to/source_directory}} {{path/to/target_directory}}
Copy a directory recursively, in verbose mode (shows files as they are copied):
cp {{[-vr|--verbose --recursive]}} {{path/to/source_directory}} {{path/to/target_directory}}
Copy multiple files at once to a directory:
cp {{[-t|--target-directory]}} {{path/to/destination_directory}} {{path/to/file1 path/to/file2 ...}}
Copy all files with a specific extension to another location, in interactive mode (prompts user before overwriting):
cp {{[-i|--interactive]}} {{*.ext}} {{path/to/target_directory}}
Follow symbolic links before copying:
cp {{[-L|--dereference]}} {{link}} {{path/to/target_directory}}
Use the full path of source files, creating any missing intermediate directories when copying:
cp --parents {{source/path/to/file}} {{path/to/target_file}}
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.