如何通过bash脚本检查文件是否存在? [英] How to check file exists via bash script?
本文介绍了如何通过bash脚本检查文件是否存在?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试克隆一个仓库,并在通过bash脚本完成后对其进行测试.我已经基于 Bash Shell编写了测试代码:检查文件是否存在.
I'm trying to clone a repo and test it after is done via bash script. I have written my test code based on Bash Shell: Check File Exists or Not.
#!/bin/bash
echo "*** TRY TO INIT INFER ***"
# Clone Infer
INFER_GIT_PATH="https://github.com/facebook/infer.git"
echo "> Try to Clone Infer from ${INFER_GIT_PATH}"
git clone ${INFER_GIT_PATH}
INFER_PATH="/infer/infer/bin/infer"
[ -e ${INFER_PATH} ] && echo "Infer downloaded successfully" || echo "Something went wrong :("
尽管回购可以成功下载并且/infer/infer/bin/infer.sh
存在,但我总是收到Something went wrong :(
消息.
Although repo can be downloaded successfully and /infer/infer/bin/infer.sh
exists, I'm always getting Something went wrong :(
message.
任何建议将不胜感激.谢谢.
Any suggestion would be appreciated. Thanks.
推荐答案
将其更改为此(使用相对路径):
Change it to this (use a relative path):
INFER_PATH="./infer/infer/bin/infer"
[ -e ${INFER_PATH} ] && echo "Infer downloaded successfully" || echo "Something went wrong :("
它应该可以工作.
这篇关于如何通过bash脚本检查文件是否存在?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文