如何将 scp 与 xargs 一起使用?

Ani*_*mj' 2 unix linux command scp xargs

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

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

find . -name "*" -type f -print0 | xargs -0 scp -r UserName@host:/path/to/destination
Run Code Online (Sandbox Code Playgroud)

但它抛出以下错误

scp: /path/to/destination: not a regular file
Run Code Online (Sandbox Code Playgroud)

Pet*_*tis 7

您需要使用 {} 将 src 文件名放在目的地之前。这是新命令:

find . -name "*" -type f -print0 | xargs -0 -I {} scp -r {} UserName@host:/path/to/destination
Run Code Online (Sandbox Code Playgroud)