2014-01-09 27 views
9

有沒有辦法使用curl複製本地文件,我需要它作爲cp命令的替代方法。使用curl複製本地文件

這有點奇怪,但我正在研究cp不可用的環境。

+1

敢肯定你不會在所有2年後護理,但我會避免使用'curl'並使用'cat' + basic shell重定向:'cat sourceFile> targ etFile' – Aaron

回答

16

你可以說:

curl -o /path/to/destination file:///path/to/source/file 

這將複製到/path/to/source/file/path/to/destination

+0

或'''curl file:/// path/to/source/file>/path/to/destination'''使用簡單的shell重定向。 –

0

可以使用rsync

rsync -avz /path/to/src/file /path/to/dst/dir 

您也可以使用tar

cd /path/to/src/dir; tar -cpf - sourcefile | (cd /path/to/dest/dir; tar -xpf -) 

如果你的焦油支持-C

cd /path/to/src/dir; tar -cpf - sourcefile | tar -xpf - -C /path/to/dest/dir