海外主机测评

您现在的位置是:首页 > 云服务器代理 > 正文

云服务器代理

检查linux文件是否存在的操作步骤

cds8202023-05-30云服务器代理74
  1.test命令  它经常用来测试条件表达式,用到的命令为test-e。  2.用bashshell检查  假设我们有文件目录/home/benben/go_project和

  1. test命令

  它经常用来测试条件表达式,用到的命令为test -e 。

  2. 用bash shell检查

  假设我们有文件目录/home/benben/go_project和文件/home/benben/go_project/test.txt,下面我们用bash shell命令来检测下这个目录和文件是否存在。

  检查目录,执行命令[-d /home/benben/go_project ] && echo "found" || echo "not found"或者[-d ./go_project ] && echo "found" || echo "not found"。

  检查文件,执行命令[-f /home/benben/go_project/test.txt ] && echo "found" || echo "not found"或者[-f ./test.txt ] && echo "found" || echo "not found"

  以上就是检查Linux文件是否存在的操作步骤的内容。

发表评论

评论列表

  • 这篇文章还没有收到评论,赶紧来抢沙发吧~