Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/27.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 如何将scp与xargs一起使用?_Linux_Unix_Command_Scp_Xargs - Fatal编程技术网

Linux 如何将scp与xargs一起使用?

Linux 如何将scp与xargs一起使用?,linux,unix,command,scp,xargs,Linux,Unix,Command,Scp,Xargs,我正在尝试将非常大的文件从一台主机移动到另一台主机。此外,文件名太大,因此我必须使用xargs。此外,还需要复制所有子目录 我正在源主机当前目录中使用以下命令 find . -name "*" -type f -print0 | xargs -0 scp -r UserName@host:/path/to/destination 但这是错误的 scp: /path/to/destination: not a regular file 您需要使用{}将src文件名放在目标文件之前。以下是新命令

我正在尝试将非常大的文件从一台主机移动到另一台主机。此外,文件名太大,因此我必须使用
xargs
。此外,还需要复制所有子目录

我正在源主机当前目录中使用以下命令

find . -name "*" -type f -print0 | xargs -0 scp -r UserName@host:/path/to/destination
但这是错误的

scp: /path/to/destination: not a regular file

您需要使用{}将src文件名放在目标文件之前。以下是新命令:

find . -name "*" -type f -print0 | xargs -0 -I {} scp -r {} UserName@host:/path/to/destination

您需要使用{}将src文件名放在目标文件之前。以下是新命令:

find . -name "*" -type f -print0 | xargs -0 -I {} scp -r {} UserName@host:/path/to/destination

差不多了,但有一件事我需要子目录也应该被复制。。但目前只移动子目录的内容。其次,该命令每次复制一个文件时都会要求输入密码。有什么解决方案吗?如果要复制目录,请从find命令中删除-f参数。如果您不想一直输入密码,请将您的公共ssh id添加到远程计算机,并使用ssh代理将您的密钥存储在您所访问的计算机上。因此我删除了
-f
,子目录的文件被复制了两次。一次在
/path/to/destination
上,另一次在
/path/to/destination/source\u文件夹上。我希望你能理解我的问题。这似乎是一个完全不同的问题。你应该发布另一个问题,详细说明你的问题和例子,有人会回答它几乎在那里,但有一件事我需要,子目录也应复制。。但目前只移动子目录的内容。其次,该命令每次复制一个文件时都会要求输入密码。有什么解决方案吗?如果要复制目录,请从find命令中删除-f参数。如果您不想一直输入密码,请将您的公共ssh id添加到远程计算机,并使用ssh代理将您的密钥存储在您所访问的计算机上。因此我删除了
-f
,子目录的文件被复制了两次。一次在
/path/to/destination
上,另一次在
/path/to/destination/source\u文件夹上。我希望你能理解我的问题。这似乎是一个完全不同的问题。你应该发布另一个问题,用例子详细说明你的问题,有人会回答的