cp
cp
[1] command is used for copying files and directories. It lacks progress bar indicator[2], but you can use progress -w
or progress -m
command to display the percentage of copied data or use rsync[3] command.
Ansible also includes a cp module with limited scalability (>hundreds of files) [4]
Options[edit]
-a, --archive
-l, --link
hard link files instead of copying-p
same as--preserve=mode,ownership,timestamps
-R, -r, --recursive
--reflink[=WHEN]
control clone/CoW copies. --reflink=always-v
verbose, showing files as they are copied.
cp --help cp: illegal option -- - usage: cp [-R [-H | -L | -P]] [-fi | -n] [-aclpsvXx] source_file target_file cp [-R [-H | -L | -P]] [-fi | -n] [-aclpsvXx] source_file ... target_directory
Examples[edit]
cp -a /source/. /dest/ cp -rp /home/origin /home/destination cp -rp /home/origin/* /home/destination/ cp file.txt file-`date --iso`.txt
- cp using Bash brace expansion:
cp /etc/httpd/httpd.{,.BAK}
cp -R -af
Activities[edit]
Related commands[edit]
rsync
mv
progress -m
copy
(Windows)nfs-cp
docker cp
minikube cp
multipass transfer
xcopy
(Windows)ADD
inDockerfile
aws s3 cp
gsutil cp
sftp cp
, since Aug 2022
See also[edit]
cp
,dd
,sftp
,scp
,rsync
,casync
,mv
,fio
,ln
,docker cp, kubectl cp
,minikube cp
,multipass transfer
,Copy-Item
,Xcopy
progress
[6]: Linux tool to show progress for cp, mv, dd. See also: pv[7] (Pipe Viewer). Example:progress -m
dd
Text is available under the Creative Commons Attribution-ShareAlike License; additional terms may apply. By using this site, you agree to the Terms of Use and Privacy Policy.
Source: https://en.wikiversity.org/wiki/Linux/Basic_commands/cp
- ↑ http://man7.org/linux/man-pages/man1/cp.1.html
- ↑ https://unix.stackexchange.com/questions/65077/is-it-possible-to-see-cp-speed-and-percent-copied
- ↑ https://stackoverflow.com/questions/6339287/copy-or-rsync-command
- ↑ https://docs.ansible.com/ansible/latest/modules/copy_module.html
- ↑ https://stackoverflow.com/questions/9392735/linux-how-to-copy-but-not-overwrite
- ↑ https://github.com/Xfennec/progress
- ↑ https://linux.die.net/man/1/pv
Advertising: