I wrote a piece of script similar to something below:srvc_location=`ps -ef| grep '${sandbox}.*pset' | head 1 | awk {print $9}`echo SERVICE LOC : $srvc_locationBut strangely this $srvc_location is getting resolved most of the time, but sometimes its not getting resolved with this message:SERVICE LOC : strrosdev_silo1_int.*psetSome additional info:The above piece of code runs in a loop so everytime $sandbox has a new value.I tried with  grep -e ${sandbox}.*pset but it didn't  solve the issue.I can solve the problem with having two grep,  grep $sandbox |grep pset,but I wanted to use just one with a pattern.Why is it behaving like this?
How to grep AND pattern with pipe
shell script;grep;pipe;ps