gpt4 book ai didi

bash - 使用 ssh 检查远程计算机上是否存在目录

转载 作者:行者123 更新时间:2023-11-29 09:04:32 26 4
gpt4 key购买 nike

这个问题已经发布,但我想知道是否有一种方法可以直接从命令行而不是从脚本中通过 ssh 知道远程机器上是否存在一个目录。正如我在之前的帖子中看到的:How to check if dir exists over ssh and return results to host machine ,我尝试在命令行中编写以下内容:

ssh armand@127.0.0.1 '[ -d Documents ]'

但这不会打印任何东西。我想知道是否有一种方法可以轻松显示答案。

最佳答案

这是一条单线:

ssh armand@127.0.0.1 '[ -d Documents ] && echo exists || echo does not exist'

关于bash - 使用 ssh 检查远程计算机上是否存在目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34008223/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com