Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux 使用curl复制本地文件_Linux_Unix_Curl - Fatal编程技术网

Linux 使用curl复制本地文件

Linux 使用curl复制本地文件,linux,unix,curl,Linux,Unix,Curl,有没有办法用curl复制本地文件,我需要它作为cp命令的替代品 这有点奇怪,但我正在一个无法使用cp的环境中工作。您可以说: curl -o /path/to/destination file:///path/to/source/file 这将把/path/to/source/file复制到/path/to/destination您可以使用rsync rsync -avz /path/to/src/file /path/to/dst/dir 你也可以用焦油 cd /path/to/src/

有没有办法用curl复制本地文件,我需要它作为cp命令的替代品

这有点奇怪,但我正在一个无法使用cp的环境中工作。

您可以说:

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

这将把
/path/to/source/file
复制到
/path/to/destination
您可以使用
rsync

rsync -avz /path/to/src/file /path/to/dst/dir
你也可以用焦油

cd /path/to/src/dir; tar -cpf - sourcefile | (cd /path/to/dest/dir; tar -xpf -)
如果您的tar支持
-C

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

很确定两年后你一点也不在乎,但我会避免
curl
,并使用
cat
+基本shell重定向:
cat sourceFile>targetFile
curlfile:///path/to/source/file >/path/to/destination
使用普通shell重定向。