linux命令——cp
cp命令主要是使用來復制文件和目錄的,
基本使用語法:
cp 源文件 目標目錄
[email protected]:~/eth10/eth10# ls test 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在復制目錄時會自動跳過目錄,因此需要使用-r
[email protected]:~/eth10/eth10# ls test1 [email protected]:~/eth10/eth10# cp test/ test1/ cp: 略過目錄‘test/‘ [email protected]:~/eth10/eth10# cp -r test/ test1/ [email protected]:~/eth10/eth10# ls test1 test
另外cp在復制文件時會自動覆蓋同名文件,因此我們可以使用-i參數來進行提示是覆蓋還是跳過,y覆蓋,n跳過!
[email protected]
最後我們可以使用-b參數,主要是對同名文件重命名(文件名後添加~
[email protected]:~/eth10/eth10# cp -b test.txt test/ [email protected]:~/eth10/eth10# ls test/ test test.txt test.txt~ [email protected]:~/eth10/eth10#
本文出自 “eth10” 博客,請務必保留此出處http://eth10.blog.51cto.com/13143704/1957498
linux命令——cp