When I run the command
ps -ef | grep -i this | head -n 1 | awk '{print $2}'
in my terminal, it gives me the correct output which gives me the PID that I need from 'this' service.
But when I try to place it in a shell script variable
PID=ps -ef | grep stress | head -n 1 | awk '{print $2}'
and try to run the script, the output is line 9: -ef: command not found
Help!