测试积点老人 发表于 2023-3-10 09:34:44

shell脚本中“if”语法如何嵌套?

回复可见
**** Hidden Message *****

kallinr 发表于 2023-3-13 09:04:07

空格

郭小贱 发表于 2023-3-13 09:18:29

https://www.zhihu.com/question/385416783可以参考这条知乎回答,比较全面的。

litingting0214 发表于 2023-3-13 09:22:02

if [ $packetanal_ver != 'yechang' ];then
   packetpid=`ps aux|greppacketAnal|grep -v "grep"|awk '{print $2}'`

   if [ "$packetpid" ];then
          kill -9 $packetpid
          echo "old packetAnal is killed"

qqq911 发表于 2023-3-13 10:10:49

if [ $packetanal_ver != 'yechang' ];then
   packetpid=`ps aux|greppacketAnal|grep -v "grep"|awk '{print $2}'`

   if [ "$packetpid" ];then
          kill -9 $packetpid
          echo "old packetAnal is killed"

bellas 发表于 2023-3-13 11:44:47


if [ $packetanal_ver != 'yechang' ];then
   packetpid=`ps aux|greppacketAnal|grep -v "grep"|awk '{print $2}'`

   if [ "$packetpid" ];then
          kill -9 $packetpid
          echo "old packetAnal is killed"

jingzizx 发表于 2023-3-13 12:33:45

没理解,按照语法来啊
页: [1]
查看完整版本: shell脚本中“if”语法如何嵌套?