Inline if shell script

后端 未结 5 1894
一向
一向 2021-02-02 06:12

Is it possible to execute shell script in command line like this :

counter=`ps -ef | grep -c \"myApplication\"`; if [ $counter -eq 1 ] then; echo \"true\";
>
         


        
5条回答
  •  失恋的感觉
    2021-02-02 06:28

    I am using Mac OS and following worked very well

    $ counter=`ps -ef | grep -c "myApplication"`; if [ $counter -eq 1 ]; then echo "true";fi;
    

    true

    Space is needed after [ and before ]

提交回复
热议问题