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\";
>
Other responses have addressed your syntax error, but I would strongly suggest you change the line to:
test $(ps -ef | grep -c myApplication) -eq 1 && echo true
If you are not trying to limit the number of occurrences to exactly 1 (eg, if you are merely trying to check for the output line myApplication and you expect it never to appear more than once) then just do:
ps -ef | grep myApplication > /dev/null && echo true
(If you need the variable counter set for later processing, neither of these solutions will be appropriate.)
Using short circuited && and || operators is often much clearer than embedding if/then constructs, especially in one-liners.