Hi All,
I am trying to fetch the particular content from the result of grep command.
I am using
ps-ef |grep engine| awk '{print $6}'
above statement giving me
/opt/test/user/domain/CORPTEST/application/CacheScheduler/CacheScheduler-CacheScheduler
but I want
CacheScheduler-CacheScheduler
the end part of that output. Please suggest your valuable suggestions to get that required output.
ps -ef | awk '/engine/{sub(/.*\//,x,$6); print $6}'
--ahamed
1 Like
Thanks ahamed, it works like a charm.
My mistake, dint mention in the first post itself.
Last word is CacheScheduler-CacheScheduler.ear
its is giving me the exact, but wanted to know if there is way to remove the.ear also from the end?
Bunch of thanks again.
ps -ef | awk '/engine/{gsub(/.*\/|\..+/,x,$6); print $6}'
--ahamed
1 Like
Jotne
August 14, 2013, 2:37am
6
@sarsour
Can you post the output of (everything it gives):
ps -ef | grep engine
Hi Ahamad,
I was trying to print some of the middle value of the string like
/opt/test/user/domain/CORPTEST/application/CacheScheduler/CacheScheduler-CacheScheduler
I want CORPTEST as the output,
I was trying using SED,
sed -e '/domain/,/application/p'|ps -ef | awk '{print $12}'
but it is dipalying the whole string only.
Jotne
August 14, 2013, 3:43am
8
Please post this
ps -ef | grep engine
It will help us to make a complete working script.
At the moment, we do not now where in your output string data is located.
I guess at the end of the line..
Hi,
here is the output of
ps -ef | grep engine
bea 14780 1 0 Aug06 ? 00:01:06 /opt/bea/osb/5.9/bin/engine --pid --run --propFile /opt/bea/ear/domain/ELINKDEV/application/Elink_ManageProducts/Elink_ManageProducts-ManageProductsService.ear --innerProcess
bea 16264 1 0 Jul12 ? 00:10:33 /opt/bea/osb/5.9/bin/engine --pid --run --propFile /opt/bea/ear/domain/ELINKDEV/application/GenericBatchProcess/GenericBatchProcess-GenericBatchProcess.ear --innerProcess
bea 20929 1 0 Jul26 ? 00:50:35 /opt/bea/osb/5.9/bin/engine --pid --run --propFile /opt/bea/ear/domain/ELINKDEV/application/MARG0TableLookUp/MARG0TableLookUp-Marg0TableLookUp_ProcessArchive.ear --innerProcess
bea 21894 1 0 Jul05 ? 00:10:53 /opt/bea/osb/5.9/bin/engine --pid --run --propFile /opt/bea/ear/domain/ELINKDEV/application/ATLANTIS_Interface/ATLANTIS_Interface-Atlantis_ProcessArchive-1.ear --innerProcess
bea 21948 1 0 Jul31 ? 00:01:55 /opt/bea/osb/5.9/bin/engine --pid --run --propFile /opt/bea/ear/domain/ELINKDEV/application/ConsolidatedAccountCreationInterface/ConsolidatedAccountCreationInterface-ESB_ConsolidatedAccountCreationInterface_Process_Archive.ear --innerProcess
bea 31414 1 0 Apr09 ? 00:14:05 /opt/bea/osb/5.9/bin/engine --pid --run --propFile /opt/bea/ear/domain/ELINKDEV/application/EOR_Test/EOR_Test-Process_Archive.ear --innerProcess
bea 32156 1 0 Jun26 ? 00:08:53 /opt/bea/osb/5.9/bin/engine --pid --run --propFile /opt/bea/ear/domain/ELINKDEV/application/Eclipse/Eclipse-EclipseProcessArchive.ear --innerProcess
bea 32585 1 0 Jun26 ? 00:07:43 /opt/bea/osb/5.9/bin/engine --pid --run --propFile /opt/bea/ear/domain/ELINKDEV/application/Oracle_ELOA/Oracle_ELOA-Oracle_ELOA_ProcessArchive.ear --innerProcess
Jotne
August 14, 2013, 3:56am
10
And from this, what is your expected output and what criteria to get it?
You like eks ELINKDEV
?
Does the output/location vary from time to time?
I also miss one line in your output
bea 22215 13041 0 09:57 pts/1 00:00:00 grep --color=auto engine
Yes Jotne, Its changing value for differnt domain, As of now I have only one domain but in higher environments , it will be multiple domains
I need value between domain and application which is the domain name. .i.e ELINKDEV
Jotne
August 14, 2013, 4:18am
12
Some like this?
ps -ef | awk -F/ '/[e]ngine/ {for (i=1;i<=NF;i++){if ($i~/domain/) {print $(i+1)}}}'
ELINKDEV
ELINKDEV
ELINKDEV
ELINKDEV
ELINKDEV
ELINKDEV
ELINKDEV
ELINKDEV
1 Like
Try this... this will print both... x[1] and x[2]...
ps -ef | awk '/engine/{match($(NF-1),"domain.(.+).appl.*/(.+)\\..+",x); print x[1],x[2]}'
--ahamed
1 Like
WOW!!!
Both solutions are working fine for me.. Thanks a ton for the kind help.
Jotne
August 14, 2013, 4:31am
15
Can you test this to:
ps -ef | awk '/domain/ {getline;print}' RS="/"