if else bash 脚本中的整数表达式预期测试或条件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8835130/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 01:17:20 来源:igfitidea点击:
integer expression expected testing or condition in if else bash scripts
提问by Registered User
In a shell script I wrote following lines gave error during execution of script
在shell脚本中,我写了以下几行在执行脚本时出错
if [ p -eq 35 -o p -eq 70 ]; then
echo "Sleeping ....zzz ........zzzz......."
sleep 5
get following error
得到以下错误
/d2.sh: line 6: [: p: integer expression expected
回答by Sven Marnach
You probably want $pinstead of p:
你可能想要$p而不是p:
if [ $p -eq 35 -o $p -eq 70 ]; then
...

