How to grep the required part from the string?

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to grep the required part from the string?
# 8  
Old 08-14-2013

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

# 9  
Old 08-14-2013
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
# 10  
Old 08-14-2013
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
# 11  
Old 08-14-2013
Some like this?
ps -ef | awk -F/ '/[e]ngine/ {for (i=1;i<=NF;i++){if ($i~/domain/) {print $(i+1)}}}'

This User Gave Thanks to Jotne For This Post:
# 12  
Old 08-14-2013
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]}'

This User Gave Thanks to ahamed101 For This Post:
# 13  
Old 08-14-2013
Both solutions are working fine for me.. Thanks a ton for the kind help.
# 14  
Old 08-14-2013
Can you test this to:
ps -ef | awk '/domain/ {getline;print}' RS="/"

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sed/awk : to grep only required pattern disk

Hi Experts, Need help with the following: Desired output: Only want to get the output marked in green. The file: --- Physical volumes --- PV Name /dev/disk/disk4704 PV Status available Total PE 6399 Free PE ... (3 Replies)
Discussion started by: rveri
3 Replies

2. Shell Programming and Scripting

Grep a part of file based on string identifiers

consider below file contents cat myOutputFIle.txt 8 CCM-HQE-ResourceHealthCheck: Resource List : No RED/UNKNOWN resource Health entries found ---------------------------------------------------------- 9 CCM-TraderLogin-Status: Number of logins: 0... (4 Replies)
Discussion started by: vivek d r
4 Replies

3. AIX

Grepping before and after lines for required string

Hi All, I am new to AIX unix . i need to grep for a pattern and if pattern is found then i need 3 before the pattern line found and 3 lines after the pattern found. (11 Replies)
Discussion started by: coolvibh
11 Replies

4. Shell Programming and Scripting

Deleting part of a string : string manipulation

i have something like this... echo "teCertificateId" | awk -F'Id' '{ print $1 }' | awk -F'te' '{ print $2 }' Certifica the awk should remove 'te' only if it is present at the start of the string.. anywhere else it should ignore it. expected output is Certificate (7 Replies)
Discussion started by: vivek d r
7 Replies

5. Shell Programming and Scripting

grep part of word or Another word from a string

Hi all, FileOne family balance >>>>> 0 0 0 0 Settings.xml (No such file or directory) at Method) .. .... ..... ..... java.lang.NullPointerException ... ..... ...... Stacktrace: at... (2 Replies)
Discussion started by: linuxadmin
2 Replies

6. Shell Programming and Scripting

searching the required string and appending string to it.

Hi all, I have some data in the form of adc|nvhs|nahssn|njadnk|nkfds in the above data i need to write a script so thet it will append "|||" to the third occurnace in the string ..... the outout should look like adc|nvhs|nahssn||||njadnk|nkfds Thanks, Firestar. (6 Replies)
Discussion started by: firestar
6 Replies

7. Shell Programming and Scripting

Help Required For String Matching

I am new to shell scripting !!!!!!!!!!.ANY HELP WOULD BE APPRECIATE :- i want to write a script that will check the log for string: waiting for seconds for this I am using :- tail -10 log.20101004 | tail -1 and grep the "string" but when matching error is coming ,see script below:- i... (1 Reply)
Discussion started by: abhigrkist
1 Replies

8. Shell Programming and Scripting

grep required data from two columns

hello, I have output from a command and I need to filter some info out of that. I tried awk command but I can not grep what I am looking for: Following is the output and I need to capture "disabled" for each volume from first column and report: # vol status Volume State ... (2 Replies)
Discussion started by: za_7565
2 Replies

9. UNIX for Dummies Questions & Answers

grep required pattern and next 2 or 3 lines

dear ones pl.kindly help me 1) how to print(grep) required pattern and following 2 or 3 lines. 2) grep required pattern(to print)+above 2 lines+below 2 or 3 lines.from a report file. ex: we have some report file kf askfjsk fksaj fk skf sjfksjd kff sjfkjs kf jskdjfklsd jfklsdf sdkfjsd fsd... (3 Replies)
Discussion started by: cvvsnm
3 Replies

10. Shell Programming and Scripting

Help required in grep command

Hi all, I need some help in grep command in a ksh script. Actually, i need to list all files having the file name like "BORD*.DAT" but exclude the files (from the list) having name like "BORD*mgt*.DAT". For that i used the following command: ls | grep "BORD*.DAT" | grep -v "BORD*mgt*.DAT" ... (4 Replies)
Discussion started by: panzer
4 Replies
Login or Register to Ask a Question