{"id":79275,"date":"2023-09-15T06:37:09","date_gmt":"2023-09-14T22:37:09","guid":{"rendered":"http:\/\/lrxjmw.cn\/?p=79275"},"modified":"2023-09-15T06:37:09","modified_gmt":"2023-09-14T22:37:09","slug":"detailed-cp-command","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/detailed-cp-command.html","title":{"rendered":"\u8fd9\u4e48\u8be6\u7ec6CP\u547d\u4ee4\u8bf4\u660e\u4f60\u786e\u5b9a\u4e0d\u6765\u770b\u770b\uff1f"},"content":{"rendered":"
\n\u540d\u79f0:cp
\n\u529f\u80fd: \u590d\u5236\u6587\u4ef6\u6216\u76ee\u5f55
\n\u8bf4\u660e: cp\u6307\u4ee4\u7528\u4e8e\u590d\u5236\u6587\u4ef6\u6216\u76ee\u5f55\uff0c\u5982\u540c\u65f6\u6307\u5b9a\u4e24\u4e2a\u4ee5\u4e0a\u7684\u6587\u4ef6\u6216\u76ee\u5f55\uff0c\u4e14\u6700\u540e\u7684\u76ee\u7684\u5730\u662f\u4e00\u4e2a\u5df2\u7ecf\u5b58\u5728\u7684\u76ee\u5f55\uff0c\u5219\u5b83\u4f1a\u628a\u524d\u9762\u6307\u5b9a\u7684\u6240\u6709\u6587\u4ef6\u6216\u76ee\u5f55\u590d\u5236\u5230\u6b64\u76ee\u5f55\u4e2d\u3002\u82e5\u540c\u65f6\u6307\u5b9a\u591a\u4e2a\u6587\u4ef6\u6216\u76ee\u5f55\uff0c\u800c\u6700\u540e\u7684\u76ee\u7684\u5730\u5e76\u975e\u4e00\u4e2a\u5df2\u5b58\u5728\u7684\u76ee\u5f55\uff0c\u5219\u4f1a\u51fa\u73b0\u9519\u8bef\u4fe1\u606f.<\/p>\n
cp(\u9009\u9879)(\u53c2\u6570)<\/pre>\n\u9009\u9879<\/strong><\/div>\n\n
- -a \u6216 --archive \u6b64\u53c2\u6570\u7684\u6548\u679c\u548c\u540c\u65f6\u6307\u5b9a\"-dpR\"\u53c2\u6570\u76f8\u540c<\/li>\n
- -b \u6216 --backup \u5220\u9664\u3001\u8986\u76d6\u76ee\u7684\u6587\u4ef6\u5148\u5907\u4efd\uff0c\u5907\u4efd\u7684\u6587\u4ef6\u6216\u76ee\u5f55\u4ea6\u5efa\u7acb\u4e3a\u7b26\u53f7\u94fe\u63a5\uff0c\u5e76\u6307\u5411\u6e90\u6587\u4ef6\u6216\u76ee\u5f55\u94fe\u63a5\u7684\u6e90\u6587\u4ef6\u6216\u76ee\u5f55\u3002\u5047\u5982\u6ca1\u6709\u52a0\u4e0a\u8fd9\u4e2a\u53c2\u6570\uff0c\u5728\u590d\u5236\u8fc7\u7a0b\u4e2d\u82e5\u9047\u5230\u7b26\u53f7\u94fe\u63a5\uff0c\u5219\u4f1a\u76f4\u63a5\u590d\u5236\u6e90\u6587\u4ef6\u6216\u76ee\u5f55<\/li>\n
- -f \u6216 --force \u5f3a\u884c\u590d\u5236\u6587\u4ef6\u6216\u76ee\u5f55\uff0c \u4e0d\u8bba\u76ee\u7684\u6587\u4ef6\u6216\u76ee\u5f55\u662f\u5426\u5df2\u7ecf\u5b58\u5728<\/li>\n
- -i \u6216 --interactive \u8986\u76d6\u6587\u4ef6\u4e4b\u524d\u5148\u8be2\u95ee\u7528\u6237<\/li>\n
- -l \u6216 --link \u5bf9\u6e90\u6587\u4ef6\u5efa\u7acb\u786c\u94fe\u63a5\uff0c\u800c\u975e\u590d\u5236\u6587\u4ef6<\/li>\n
- -p \u6216 --preserve \u4fdd\u7559\u6e90\u6587\u4ef6\u6216\u76ee\u5f55\u7684\u5c5e\u6027\uff0c\u5305\u62ec\u6240\u6709\u8005\u3001\u6240\u5c5e\u7ec4\u3001\u6743\u9650\u4e0e\u65f6\u95f4<\/li>\n
- -P \u6216 --parents \u4fdd\u7559\u6e90\u6587\u4ef6\u6216\u76ee\u5f55\u7684\u8def\u5f84\uff0c\u6b64\u8def\u5f84\u53ef\u4ee5\u662f\u7edd\u5bf9\u8def\u5f84\u6216\u76f8\u5bf9\u8def\u5f84\uff0c\u4e14\u76ee\u7684\u76ee\u5f55\u5fc5\u987b\u5df2\u7ecf\u4e30\u5728<\/li>\n
- -r \u9012\u5f52\u5904\u7406\uff0c\u5c06\u6307\u5b9a\u76ee\u5f55\u4e0b\u7684\u6587\u4ef6\u4e0e\u5b50\u76ee\u5f55\u4e00\u5e76\u5904\u7406\u3002\u82e5\u6e90\u6587\u4ef6\u6216\u76ee\u5f55\u7684\u5f62\u6001\uff0c\u4e0d\u5c5e\u4e8e\u76ee\u5f55\u6216\u7b26\u53f7\u94fe\u63a5\uff0c\u5219\u4e00\u5f8b\u89c6\u4e3a\u666e\u901a\u6587\u4ef6\u5904\u7406<\/li>\n
- -R \u6216 --recursive \u9012\u5f52\u5904\u7406\uff0c\u5c06\u6307\u5b9a\u76ee\u5f55\u4e0b\u7684\u6587\u4ef6\u53ca\u5b50\u76ee\u5f55\u4e00\u5e76\u5904\u7406<\/li>\n
- -s \u6216 --symbolic-link \u5bf9\u6e90\u6587\u4ef6\u5efa\u7acb\u7b26\u53f7\u94fe\u63a5\uff0c\u800c\u975e\u590d\u5236\u6587\u4ef6<\/li>\n
- -S <\u5907\u4efd\u5b57\u5c3e\u5b57\u7b26\u4e32> \u6216 --suffix=<\u5907\u4efd\u5b57\u5c3e\u5b57\u7b26\u4e32> \u7528\"-b\"\u53c2\u6570\u5907\u4efd\u76ee\u7684\u6587\u4ef6\u540e\uff0c\u5907\u4efd\u6587\u4ef6\u7684\u5b57\u5c3e\u4f1a\u88ab\u52a0\u4e0a\u4e00\u4e2a\u5907\u4efd\u5b57\u7b26\u4e32\u3002\u9ed8\u8ba4\u7684\u5907\u4efd\u5b57\u5c3e\u7b26\u4e32\u662f\u7b26\u53f7\"~\"<\/li>\n
- -u \u6216 --update \u4f7f\u7528\u8fd9\u9879\u53c2\u6570\u4e4b\u540e\uff0c\u53ea\u4f1a\u5728\u6e90\u6587\u4ef6\u7684\u4fee\u6539\u65f6\u95f4(Modification Time)\u8f83\u76ee\u7684\u6587\u4ef6\u66f4\u65b0\u65f6\uff0c\u6216\u662f\u540d\u79f0\u76f8\u4e92\u5bf9\u5e94\u7684\u76ee\u7684\u6587\u4ef6\u5e76\u4e0d\u5b58\u5728\uff0c\u624d\u590d\u5236\u6587\u4ef6<\/li>\n
- -v \u6216 --verbose \u663e\u793a\u6267\u884c\u8fc7\u7a0b<\/li>\n
- -V <\u5907\u4efd\u65b9\u5f0f> \u6216 --version-control=<\u5907\u4efd\u65b9\u5f0f> \u6307\u5b9a\u5f53\u5907\u4efd\u6587\u4ef6\u65f6\uff0c\u5907\u4efd\u6587\u4ef6\u540d\u7684\u547d\u540d\u65b9\u5f0f\uff0c\u6709\u4ee5\u4e0b3\u79cd:\n
\n
- numbered\u6216t, \u5c06\u4f7f\u7528\u5907\u4efd\u7f16\u53f7\uff0c\u4f1a\u5728\u5b57\u5c3e\u52a0\u4e0a~1~\u5b57\u7b26\u4e32\uff0c\u5176\u6570\u5b57\u7f16\u53f7\u4f9d\u6b21\u9012\u589e<\/li>\n
- simple\u6216never \u5c06\u4f7f\u7528\u7b80\u5355\u5907\u4efd\uff0c\u9ed8\u8ba4\u7684\u5907\u4efd\u5b57\u5c3e\u5b57\u7b26\u4e32\u662f~, \u4e5f\u53ef\u901a\u8fc7-S\u6765\u6307\u5b9a<\/li>\n
- existing\u6216nil\u5c06\u4f7f\u7528\u5f53\u524d\u65b9\u5f0f\uff0c\u7a0b\u5e8f\u4f1a\u5148\u68c0\u67e5\u662f\u5426\u5b58\u5728\u7740\u5907\u4efd\u7f16\u53f7\uff0c\u82e5\u6709\u5219\u91c7\u7528\u5907\u4efd\u7f16\u53f7\uff0c\u82e5\u65e0\u5219\u91c7\u7528\u7b80\u5355\u5907\u4efd<\/li>\n<\/ol>\n<\/li>\n
- -x \u6216 --one-file-system \u590d\u5236\u7684\u6587\u4ef6\u6216\u76ee\u5f55\u5b58\u653e\u7684\u6587\u4ef6\u7cfb\u7edf\uff0c\u5fc5\u987b\u4e0ecp\u6307\u4ee4\u6267\u884c\u65f6\u6240\u5904\u7684\u6587\u4ef6\u7cfb\u7edf\u76f8\u540c\uff0c\u5426\u5219\u4e0d\u590d\u5236\uff0c\u4ea6\u4e0d\u5904\u7406\u4f4d\u4e8e\u5176\u4ed6\u5206\u533a\u7684\u6587\u4ef6<\/li>\n
- --help \u663e\u793a\u5728\u7ebf\u5e2e\u52a9<\/li>\n
- --sparse=<\u4f7f\u7528\u65f6\u673a> \u8bbe\u7f6e\u4fdd\u5b58\u5e0c\u758f\u6587\u4ef6\u7684\u65f6\u673a<\/li>\n
- --version \u663e\u793a\u7248\u672c<\/li>\n
- <\/li>\n<\/ul>\n
\u793a\u4f8b<\/strong><\/div>\n\u590d\u5236\u6587\u4ef6\uff0c\u53ea\u6709\u6e90\u6587\u4ef6\u8f83\u76ee\u7684\u6587\u4ef6\u7684\u4fee\u6539\u65f6\u95f4\u65b0\u65f6\uff0c\u624d\u590d\u5236\u6587\u4ef6<\/strong><\/span><\/div>\ncp -u -v file1 file2<\/pre>\n\u5c06\u6587\u4ef6file1\u590d\u5236\u6210\u6587\u4ef6file2<\/strong><\/span><\/div>\ncp file1 file2<\/pre>\n\u91c7\u7528\u4ea4\u4e92\u65b9\u5f0f\u5c06\u6587\u4ef6file1\u590d\u5236\u6210\u6587\u4ef6file2<\/strong><\/span><\/div>\ncp -i file1 file2<\/pre>\n.\u5c06\u6587\u4ef6file1\u590d\u5236\u6210file2\uff0c\u56e0\u4e3a\u76ee\u7684\u6587\u4ef6\u5df2\u7ecf\u5b58\u5728\uff0c\u6240\u4ee5\u6307\u5b9a\u4f7f\u7528\u5f3a\u5236\u590d\u5236\u7684\u6a21\u5f0f<\/strong><\/span><\/div>\ncp -f file1 file2<\/pre>\n\u5c06\u76ee\u5f55dir1\u590d\u5236\u6210\u76ee\u5f55dir2<\/strong><\/span><\/div>\ncp -R file1 file2<\/pre>\n\u540c\u65f6\u5c06\u6587\u4ef6file1\u3001file2\u3001file3\u4e0e\u76ee\u5f55dir1\u590d\u5236\u5230dir2<\/strong><\/span><\/div>\ncp -R file1 file2 file3 dir1 dir2<\/pre>\n\u590d\u5236\u65f6\u4fdd\u7559\u6587\u4ef6\u5c5e\u6027<\/strong><\/span><\/div>\ncp -p a.txt tmp\/<\/pre>\n\u590d\u5236\u65f6\u4fdd\u7559\u6587\u4ef6\u7684\u76ee\u5f55\u7ed3\u6784<\/strong><\/span><\/div>\ncp -P \/var\/tmp\/a.txt .\/temp\/<\/pre>\n\u590d\u5236\u65f6\u4ea7\u751f\u5907\u4efd\u6587\u4ef6<\/strong><\/span><\/div>\ncp -b a.txt tmp\/<\/pre>\n\u590d\u5236\u65f6\u4ea7\u751f\u5907\u4efd\u6587\u4ef6\uff0c\u5c3e\u6807 ~1~\u683c\u5f0f<\/strong><\/span><\/div>\ncp -b -V t a.txt \/tmp<\/pre>\n\u6307\u5b9a\u5907\u4efd\u6587\u4ef6\u5c3e\u6807<\/strong><\/span><\/div>\ncp -b -S _bak a.txt \/tmp<\/pre>\n\n\u539f\u6587\u6765\u81ea\uff1ahttp:\/\/www.linuxidc.com\/Linux\/2017-08\/146019.htm<\/a><\/p>\n