Hi, I'm trying to grep appln processes using its filesystem and also using awk to get accurate results, however when i'm uisng the filesystem in awk statement i'm getting error. Requesting help.
sorry for delay. Ravinder: yes, your suggested code did work; Thank you.
M.i.Germany: ps -eaf | grep '[A]pplnName' | awk 'index($0,"/opt/xxx/yyy")' worked for me. Thank you.
RudiC: your suggestion did work for me. Learnt a new awk thing regarding selecting processes. Thank you.
---------- Post updated at 05:14 PM ---------- Previous update was at 05:00 PM ----------
but one thing i'm not clear is the option -x which shows command line in extended format for the "ps" command. I saw an "-x" added to "ps" command in another script. I just added "-x" to the code suggested above by you all. And i got the exact count (11) of the processes for that ApplnName. If i didn't add "-x", i am getting the correct output but with 3 other processes missed. Not clear what difference "-x" made? I did go thru the 'man' page of 'ps' command and got to know that '-x' shows command line in extended format. But not very clear about it.
In fact, this is NOT an " awk thing regarding selecting processes" - it's one of the strengthes of awk to match regexes found in the input (text) stream. ps output IS text, and it happens to contain the "applname" word (or not).
Depending on the system that you work on - which you fail to mention, BTW - ps comes in various flavours. Guessing from the options you use in post#1, you're on a linux system? From its man ps :
-x is one of them - read carefully what it really does for you. Me personally, I don't think its needed (in non-BSD systems).
I'm on HP-UX B.11.23. Amazed to see the function of awk in this case & realized output of ps command is also a data in tabular format which awk deals with. Need to dig deeper in awk.