Awk Script: Nested search using different patter


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Awk Script: Nested search using different patter
# 1  
Old 12-11-2009
Awk Script: Nested search using different patter

Hi Friends.

Please have a look at dummy file. I need to extract from this file:

1. Counts of event=
2. the 2nd coulmn is unique call id of this transaction. Based on that, i have to search for txstatus= .

Note: Values of event, calltype and txstatus can be anything.

I want to print the output something like:

No of event x:
No of event y:

txstatus x:
txstatus y:

In sample record event is callstart. it could be anything. Can i take it as variable and print the samething which is coming in file? similar for txstatus also. I need this to make it more dynamic and avoid hard codings of status etc....



====================

1260413928.455 1bc0c74a-d811-4b63-b602-b8bb044ebef3 event=callstart calltype=Deposit circuitid=0
1260413939.121 1bc0c74a-d811-4b63-b602-b8bb044ebef3 event=txend txid=2 txstatus=success
# 2  
Old 12-12-2009
I don't have enough information on what the file looks like and what needs to be done. Can you make a better example of what the real file looks like and how it needs to be processed?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk - multiple and nested if-then-else

Hello. I would like to convert the following piece of code from bash to awk. Here are bash variables in a bash script. CUR_ROW_ID and ROW_ID_TO_SEARCH contains a string which represent a row id. The string contain a valid row id. CUR_ROW_ID sometimes may be null. CUR_VALUE... (3 Replies)
Discussion started by: jcdole
3 Replies

2. Shell Programming and Scripting

awk nested looping?

I am trying to parse a text file and send its output to another file but I am having trouble conceptualizing how I am supposed to do this in awk. The text file has a organization like so: Name Date Status Location (city, state, zip fields) Where each of these is on a separate line in... (1 Reply)
Discussion started by: kellyanneghj
1 Replies

3. Shell Programming and Scripting

awk script for contains search

I need help in awk script to do contains search and my requirement is below I need to check if the value in each column is present in any other column and print it. And in some columns these value could be existing with comma as delimiter. Sample data... (6 Replies)
Discussion started by: aramacha
6 Replies

4. Shell Programming and Scripting

Nested search in a file and replace the inner search

Hi Team, I am new to unix, please help me in this. I have a file named properties. The content of the file is : ##Mobile props east.url=https://qa.east.corp.com/prop/end west.url=https://qa.west.corp.com/prop/end south.url=https://qa.south.corp.com/prop/end... (2 Replies)
Discussion started by: tolearn
2 Replies

5. Shell Programming and Scripting

Nested awk Statements

Hello again everyone, yes, I'm back again for more help! So I'm attempting to read two separate files and generate some XML code from that. My current code is: BEGIN { print "<?xml version=\"1.0\" encoding=\"utf-8\">" print "<Export>" } { x=1; print "<section name=\"Query" NR "\">"... (5 Replies)
Discussion started by: Parrakarry
5 Replies

6. Shell Programming and Scripting

Script using Sed :Search all patterns & after the last Patter, insert a newLine with Comma Sep Value

I am trying to search the pattern "ARS (11)" and after the LAST pattern, i am trying to open new line and enter text using sed. My Existing Text file is Users.txtpaul, Paul Smith, Stevn Smiley, REQ000001, ARS (11) sam, Sam Martin, Stevn Smiley, REQ000001, ARS (11) mike, Mike Conway, Stevn... (8 Replies)
Discussion started by: evrurs
8 Replies

7. Shell Programming and Scripting

Nested case inside awk

please let me know if the below code could be written efficiently inside single awk case "$INP" in ksh) cat catalog | awk 'BEGIN {FS=",";} { print $2 } END {}' ;; pset) cat catalog | awk 'BEGIN {FS=",";} { print $3 } END {}' ;; dml) cat catalog | awk 'BEGIN {FS=",";} {... (2 Replies)
Discussion started by: cvsanthosh
2 Replies

8. Shell Programming and Scripting

nested functions search

I want to write a shell script which traverses a cpp file. Suppose there is function fncn_name6 .. which is called by fncn_name5 which in turn called by fncn_name4 and so on .. in a single cpp class. ie fncn_name1 { fncn_name2 { fncn_name3 } { fncn_name4 ... (0 Replies)
Discussion started by: ultimatix
0 Replies

9. UNIX for Advanced & Expert Users

sed in awk ? or nested awk ?

Hey all, Can I put sed command inside the awk action ?? If not then can i do grep in the awk action ?? For ex: awk '$1=="174" { ppid=($2) ; sed -n '/$ppid/p' tempfind.txt ; }' tempfind.txt Assume: 174 is string. Assume: tempfind.txt is used for awk and sed both. tempfind.txt... (11 Replies)
Discussion started by: varungupta
11 Replies

10. Shell Programming and Scripting

awk 2 delimiter nested

Hello All, This work could be very easy for you guys. I would really appreciate help. input file: output file: (Desired) What I am capable of doing: Command: cat inputfile | awk -F\| '{print "num="$1" value="$2" digits="$3" name1="$4" file="$5" code="$6}' > outputfile Result what I am... (5 Replies)
Discussion started by: onlyroshni
5 Replies
Login or Register to Ask a Question