使用ssh检查目录在远程计算机上是否存在 [英] Check if directory exists on remote machine with ssh
本文介绍了使用ssh检查目录在远程计算机上是否存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这个问题已经发布,但是我想知道是否有一种方法可以直接从命令行(而不是从脚本)通过ssh BUT知道远程计算机上是否存在目录.正如我在上一篇文章中看到的那样:
This question has been already posted but I would like to know if there is a way to know if a directory exists on a remote machine with ssh BUT from the command line directly and not from a script. As I saw in this previous post: How to check if dir exists over ssh and return results to host machine, I tried to write in the command line the following:
ssh armand@127.0.0.1 '[ -d Documents ]'
但这不会打印任何内容.我想知道是否有一种容易显示答案的方法.
But this does not print anything. I would like to know if there's a way to display an answer easily.
推荐答案
这是一个班轮:
ssh armand@127.0.0.1 '[ -d Documents ] && echo exists || echo does not exist'
这篇关于使用ssh检查目录在远程计算机上是否存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文