Since you have not provided any sample output of your ps command (piped through grep and awk), I can only guess that you expect it to return a single string on a single line. Based on the "if" statement in your original code, I assumed that if the output of ps was not equal to the magic literal string 'weblogic', then you wanted to execute your $com2 command.