The CP command is used primarily to copy files and directories,
Basic usage Syntax:
CP Source File Destination Directory
[Email protected]:~/eth10/eth10# lstest test.txt[email protected]:~/eth10/eth10# ls test[email protected]:~/eth10/ eth10# cp test.txt test/[email protected]:~/eth10/eth10# ls test/test.txt[email protected]:~/eth10/eth10#
CP automatically skips directories when replicating directories, so you need to use the- r parameter for replication
[email protected]:~/eth10/eth10# ls test1[email protected]:~/eth10/eth10# cp test/test1/cp: Skip directory ' test/' [email protected]:~/eth10/eth10# cp-r test/test1/[email protected]:~/eth10/eth10# ls test1test
In addition CP will automatically overwrite files with the same name when copying files, so we can use the-I parameter to indicate whether to overwrite or skip,y overwrite,n Skip!
[Email protected]:~/eth10/eth10# lstest test1 test.txt[email protected]:~/eth10/eth10# cp test.txt Test[email protected ]:~/eth10/eth10# ls testtest test.txt[email protected]:~/eth10/eth10# cp-i test.txt TEST/CP: Do you want to overwrite ' test/test.txt '? N[email protected]:~/eth10/eth10#
Finally we can use the- b parameter, which is mainly to rename the file with the same name (add ~after file name) before copying
[Email protected]:~/eth10/eth10# cp-b test.txt test/[email protected]:~/eth10/eth10# ls test/test test.txt test.txt~[em Ail protected]:~/eth10/eth10#
This article is from the "eth10" blog, make sure to keep this source http://eth10.blog.51cto.com/13143704/1957498
Linux command--CP