shell编写错误合集

jms_num='ps -ef|grep Ris|grep -v grep|grep -v sh|wc -l'

if [ $jms_num==1 ]
run1.sh: line 7: [: too many arguments           --------------变量加引号 “$jms_num”

"$jms_num" -eq 1
run1.sh: line 7: [: ps -ef|grep Ris|grep -v grep|wc -l: integer expression expected   ------把 -eq 改为 ==

if ["$jms_num" -eq 1]
run1.sh: line 7: [ps -ef|grep Ris|grep -v grep|wc -l: command not found  ------if后面的中括号,中括号和里面的表达式之间要空格

 for pid in $(ps -ef|grep Ris|grep -v grep|grep -v sh|awk '{print $2}')

原文地址:https://www.cnblogs.com/xiaofeng91/p/15070208.html