【发布时间】:2017-03-12 15:42:02
【问题描述】:
我想问一个关于 shell 脚本的问题
假设有两个路径可以安装文件
Path_1 或 Path_2
脚本首先应该在Path_1 上查找文件
如果文件不存在或未安装在Path_1
那么脚本应该在path_2 上查找文件
如果它也不在那里,则显示 error
我有这个
代码:-# Make sure that sh.exe is found in C:\Program Files (x86)\Git\bin\sh.exe
ls /c/Program\ Files\ \(x86\)/Git/bin/sh.exe > /dev/null 2>&1 || {
echo
echo -e "\t Git Bash was not installed in the default location."
echo -e '\t Installation requires sh.exe to be found at C:\Program Files (x86)\Git\\bin\sh.exe.'
echo
echo -e "\e[0;31mAborting...\e[m"
waitForEnterAndExit
}
echo -e "\t Git Bash installation found in C:\Program Files (x86)/Git/bin/sh.exe"
现在sh.exe可以安装在
C:\Program Files\Git\bin
或
C:\Program Files (x86)\Git\bin\sh.exe
现在我想更改脚本,以便它首先在
处检查文件C:\Program Files\Git\bin
如果文件不存在则在
C:\Program Files (x86)\Git\bin\sh.exe
【问题讨论】:
-
你自己做了什么来找到答案的?
-
尝试谷歌搜索
"bash file exists"