Hello,
I am new to AWK and in UNIX in general. I am hoping you can help me out here.
Here is my data:
root@ubuntu:~# cat circuits.list
WORD1
AA
BB
CC
DD
Active
ISP1
ISP NAME1
XX-XXXXXX1
WORD1
AA
BB
CC
DD
Active
ISP2
ISP NAME2
XX-XXXXX2
WORD2
AA
BB
CC
DD
Active
ISP1
ISP NAME1
XX-XXXXX1
WORD2
AA
BB
CC
DD
Active
ISP2
ISP NAME2
XX-XXXXX2
I would like to skip AA up to DD and Create an output like this:
Location: WORD1
Status: Active
Service Type: ISP1
Service Provider: ISP NAME1
Name ID: XX-XX-XXX1
Location: WORD1
Status: Active
Service Type: ISP2
Service Provider: ISP NAME2
Name ID: XX-XX-XXX2
My current command is the one written below but AA-DD is getting in the way. Please help!
root@ubuntu:~# awk '
BEGIN{split("Location,Status,Service Type,Service Provider,ID",h,",")}
/WORD1/{print""; c=7}
c&&c--&&c!=1&&c!=0{print h[7-c]": " $0}' circuits.list
Output:
Location: WORD1
Status: AA
Service Type: BB
Service Provider: CC
ID: DD
Location: WORD1
Status: AA
Service Type: BB
Service Provider: CC
ID: DD