Hi bipinajith
Thanks for help.
output is coming but with some more extra lines after executing your code
HTML Code:
/usr/xpg4/bin/awk '/^[a-zA-Z]/ {
if(/^Card Status/||/^Max Circuits/||/^Num Circuits \(TOTAL\)/)
f=1;
else
f=0;
} f==1 {
print;
} /^IP/ {
print $NF;
} /#/ {
sub(/.*]/,x);
sub(/#.*/,x);
print;
}' n1
Output
HTML Code:
10.238.52.65
pun-ras-bng-mhs-01
pun-ras-bng-mhs-01
pun-ras-bng-mhs-01
Card Status : 1:0, 2:1, 3:1, 4:1, 5:0, 6:0, 7:0,
8:0, 9:1, 10:0, 11:0, 12:0, 13:0, 14:1,
Max Circuits: 1: 0, 2: 32768, 3: 32768, 4: 32768, 5: 0,
6: 0, 7: 0, 8: 0, 9: 16384, 10: 0,
11: 0, 12: 0, 13: 0, 14: 4096,
Num Circuits (TOTAL):
1: 4, 2: 8959, 3: 10591, 4: 4, 5: 4,
6: 0, 7: 1, 8: 0, 9: 12, 10: 0,
11: 0, 12: 0, 13: 0, 14: 1,
0
pun-ras-bng-mhs-01
10.238.54.1
enk-ras-bng-cse-01
enk-ras-bng-cse-01
enk-ras-bng-cse-01
Card Status : 1:1, 2:1, 3:1, 4:1, 5:0, 6:0, 7:0,
8:0, 9:1, 10:0, 11:0, 12:0, 13:0, 14:0,
Max Circuits: 1: 32768, 2: 32768, 3: 32768, 4: 32768, 5: 0,
6: 0, 7: 0, 8: 0, 9: 16384, 10: 0,
11: 0, 12: 0, 13: 0, 14: 0,
Num Circuits (TOTAL):
1: 4916, 2: 10976, 3: 9385, 4: 7, 5: 0,
6: 0, 7: 1, 8: 0, 9: 14, 10: 0,
11: 0, 12: 0, 13: 0, 14: 0,
0
enk-ras-bng-cse-01
10.238.56.225
ngp-ras-bng-cto-01
ngp-ras-bng-cto-01
ngp-ras-bng-cto-01
Card Status : 1:0, 2:1, 3:1, 4:0, 5:1, 6:1, 7:0,
8:0, 9:1, 10:0, 11:0, 12:0, 13:0, 14:0,
Max Circuits: 1: 0, 2: 32768, 3: 32768, 4: 0, 5: 32768,
6: 32768, 7: 0, 8: 0, 9: 16384, 10: 0,
11: 0, 12: 0, 13: 0, 14: 0,
Num Circuits (TOTAL):
1: 0, 2: 18651, 3: 6325, 4: 0, 5: 4,
6: 1, 7: 1, 8: 0, 9: 13, 10: 0,
11: 0, 12: 0, 13: 0, 14: 0,
0
ngp-ras-bng-cto-01
I made small change in code ,used different key word ,now output is coming as desired.
HTML Code:
/usr/xpg4/bin/awk '/^[a-zA-Z]/ {
if(/^Card Status/||/^Max Circuits/||/^Num Circuits \(TOTAL\)/)
f=1;
else
f=0;
} f==1 {
print;
} /IP IS/ {
IP=$3 ;print IP;
} /context/ {
sub(/.*]/,x);
sub(/#.*/,x);
print;
}' n1
output file
HTML Code:
10.238.52.65
pun-ras-bng-mhs-01
Card Status : 1:0, 2:1, 3:1, 4:1, 5:0, 6:0, 7:0,
8:0, 9:1, 10:0, 11:0, 12:0, 13:0, 14:1,
Max Circuits: 1: 0, 2: 32768, 3: 32768, 4: 32768, 5: 0,
6: 0, 7: 0, 8: 0, 9: 16384, 10: 0,
11: 0, 12: 0, 13: 0, 14: 4096,
Num Circuits (TOTAL):
1: 4, 2: 8959, 3: 10591, 4: 4, 5: 4,
6: 0, 7: 1, 8: 0, 9: 12, 10: 0,
11: 0, 12: 0, 13: 0, 14: 1,
10.238.54.1
enk-ras-bng-cse-01
Card Status : 1:1, 2:1, 3:1, 4:1, 5:0, 6:0, 7:0,
8:0, 9:1, 10:0, 11:0, 12:0, 13:0, 14:0,
Max Circuits: 1: 32768, 2: 32768, 3: 32768, 4: 32768, 5: 0,
6: 0, 7: 0, 8: 0, 9: 16384, 10: 0,
11: 0, 12: 0, 13: 0, 14: 0,
Num Circuits (TOTAL):
1: 4916, 2: 10976, 3: 9385, 4: 7, 5: 0,
6: 0, 7: 1, 8: 0, 9: 14, 10: 0,
11: 0, 12: 0, 13: 0, 14: 0,
10.238.56.225
ngp-ras-bng-cto-01
Card Status : 1:0, 2:1, 3:1, 4:0, 5:1, 6:1, 7:0,
8:0, 9:1, 10:0, 11:0, 12:0, 13:0, 14:0,
Max Circuits: 1: 0, 2: 32768, 3: 32768, 4: 0, 5: 32768,
6: 32768, 7: 0, 8: 0, 9: 16384, 10: 0,
11: 0, 12: 0, 13: 0, 14: 0,
Num Circuits (TOTAL):
1: 0, 2: 18651, 3: 6325, 4: 0, 5: 4,
6: 1, 7: 1, 8: 0, 9: 13, 10: 0,
11: 0, 12: 0, 13: 0, 14: 0,
thanks again ,you made my work easier.
Moderator's Comments:
|
|
Please view this code tag video for how to use code tags when posting code and data.
|
|
---------- Post updated at 11:24 PM ---------- Previous update was at 10:27 AM ----------
Hi
any body can help to get the same output like in below format from input file in previous post.
HTML Code:
IP HOST NAME Card No card status Maximum circuits Total circuits
10.238.48.1 bgl-ras-bng-bge-01 1 1 32768 6628
10.238.48.1 bgl-ras-bng-bge-01 2 1 32768 8186
0.238.48.1 bgl-ras-bng-bge-01 3 1 32768 4
10.238.48.1 bgl-ras-bng-bge-01 4 1 32768 5247
10.238.48.1 bgl-ras-bng-bge-01 5 0 0 0
10.238.48.1 bgl-ras-bng-bge-01 6 0 0 0
10.238.48.1 bgl-ras-bng-bge-01 7 0 0 0
10.238.48.1 bgl-ras-bng-bge-01 8 0 0 0
10.238.48.1 bgl-ras-bng-bge-01 9 1 16384 124
10.238.48.1 bgl-ras-bng-bge-01 10 0 0 0
10.238.48.1 bgl-ras-bng-bge-01 11 0 0 0
10.238.48.1 bgl-ras-bng-bge-01 12 0 0 0
10.238.48.1 bgl-ras-bng-bge-01 13 0 0 0
10.238.48.1 bgl-ras-bng-bge-01 14 1 4096 1