11-12-2009
Thanks for quick update.
I'm working with a file that does not have fixed field numbers, some records have additional name and value. I want to make single line from each set ex: from policy to exit, then I want to print the value of id, name, address(multiple addresses) by finding the pattern (id, name ..etc)
awk '/policy/,/exit/{ if($0~/exit/) ORS="\n"; else ORS=" "; print}' input > tmp
I want to read tmp and find next word (value) of matched pattern (id, name, etc)
first record
policy glb id 1233 name Permit ping from "One" to "Second" "Address1" "Any" "ICMP-ANY" permit
policy id 1233
service "snmp-udp"
exit
second record
policy id 1234 name Permit ping from "One" to "Second" address "Address1" "Any" "ICMP-ANY" permit
policy id 1234
address "xyzabc"
address "12345"
service "snmp-udp"
exit
Expected output:
id name from to address service
1234 Permit Ping One Second Address1 snmp-udp
1234 Permit Ping One Second xyzabc snmp-udp
1234 Permit ping One Second 12345 snmp-udp
Last edited by baskar; 11-12-2009 at 11:45 PM..
9 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I am an Awk newbie and cannot wrap my brain around my problem:
Given multi-line records of varying lengths separated by a blank line I need to skip the first two lines
of every record and extract every-other line in each record unless the first line of the record has the word "(CONT)" in the... (10 Replies)
Discussion started by: RacerX
10 Replies
2. UNIX for Dummies Questions & Answers
Hi,
I have a file that contains some records that I would like to process
each line that I am interested in. My goal is to create a new file that contains only the rest_of_line for each line that matches.
It has the following File Format
command, platform, rest_of_line"
I am searching the... (2 Replies)
Discussion started by: CAGIRL
2 Replies
3. Shell Programming and Scripting
hi,
i have records like this
supplier,product, persons involved
10,150,ravi@yahoo.com
30,200,ravi@yahoo.com
20,111,payal@gmail.com
40,211,ravi@yahoo.com
i want to write a command which displays values like this
10,30,40,ravi@yahoo.com
for ravi@yahoo.com if there are n number of... (7 Replies)
Discussion started by: trichyselva
7 Replies
4. Shell Programming and Scripting
hi,
I have records like this
D127@dm.com,127,569,BRAD,25/08/2009 23:59
D127@dm.com,127,569,BRAD,25/08/2009 23:59
D159@dm.com,159,1170,DAVE,25/08/2009 23:59
D159@dm.com,159,1181,HALE,25/08/2009 23:59
D393@dm.com,393,1209,CAPIT,25/08/2009 23:59
D457@dm.com,457,571,NORTT,25/08/2009 23:59... (4 Replies)
Discussion started by: trichyselva
4 Replies
5. UNIX for Dummies Questions & Answers
input:
ref.1;rack.1;1 #group1
ref.1;rack.1;2 #group1
ref.1;rack.2;1 #group2
ref.2;rack.3;1 #group3
ref.2;rack.3;2 #group3
ref.2;rack.3;3 #group3
Among records from same group (i.e. with same 1st and 2nd field - separated by ";"), I would need to keep the last record... (5 Replies)
Discussion started by: beca123456
5 Replies
6. Programming
Hello,
I extracted a list of files in a directory with the command ls . However this is not my computer, so the ls functionality has been revamped so that it gives the filesizes in front like this :
This is the output of ls command : I stored the output in a file filelist
1.1M... (5 Replies)
Discussion started by: ajayram
5 Replies
7. Shell Programming and Scripting
Hi,
I want to read multiple records from oracle database table and then based on each record I need to do some file modifications in UNIX.
I'm not sure how do I process each record from DB in UNIX.Below is the code snippet.
sqlplus user/pwd@DEV
for i IN (select * from table)
loop
-- for... (2 Replies)
Discussion started by: prats_7678
2 Replies
8. UNIX for Beginners Questions & Answers
Hi,
My input looks like that:
A|123|qwer
A|456|tyui
A|456|wsxe
B|789|dfgh
Using awk, I am trying to get:
A|123;456|qwer;tyui;wsxe
B|789|dfgh
For records with same $1, group all the $2 in a field (without replicates), and all the $3 in a field (without replicates).
What I have tried:... (6 Replies)
Discussion started by: beca123456
6 Replies
9. Shell Programming and Scripting
Hi All,
I am using RHEL 6.9. I got a requirement to group the records in a file.The file content as shown below.
#### FAILED JOBS IN XXX #####
1> ABCD failed in the project XXX
2> HJK Job is in compiled state in the project XXX
3> ILKD failed in the project XXX
4> DFG failed in the... (5 Replies)
Discussion started by: ginrkf
5 Replies