【发布时间】:2021-07-02 19:09:43
【问题描述】:
我正在尝试读取特定文件的内容。我有多个这些文件所在的主机。我在 ssh 期间传递以下命令,以便它可以运行并获取输出。
-
当使用下面的命令时,我得到了指定的错误。 (它的 sshed 托管但没有任何反应)
$ ssh host "more $(find /my/path -name "test*")" find: 0652-010 The starting directory is not valid. -
当使用 exec 时它不起作用,(它的 sshed 到主机但没有任何反应)
$ ssh host "find /my/path -name "test*" -exec more {} \;"` -
当使用 xargs 时,它按预期工作
$ ssh host "find /my/path -name "test*" | xargs more"
有人能解释一下为什么方法 1 和 2 不起作用吗?
请注意,如果我直接在远程主机上运行命令,则每种方法都可以正常工作。 例如,以下所有命令在远程主机中都按预期工作。
more $(find /my/path -name "test*")
find /my/path -name "test*" -exec more {} \;
find /my/path -name "test*" | xargs more
【问题讨论】:
标签: linux bash unix ssh solaris