09-28-2011
Chubler_XL
Man that was awesome, It worked really cool.. Thanks again for your time and bearing with me this script!!!!
Saludos.
---------- Post updated at 07:54 AM ---------- Previous update was at 07:37 AM ----------
One more help, Last time I did not realize about some categories might display several times in the input file. For example, category BAOC, it has 4 occurrences, so I need to extract that category and the column beside called STATUS separated by commas
OUTPUT
Code :
67807532,714011000643614,OBO-0,OBR-2,OBI-0,TS21-1,OICK-24,TICK-11,1,2
Input File
Code :
hgsdp:msisdn=50767807532,all;
HLR SUBSCRIBER DATA
SUBSCRIBER IDENTITY
MSISDN IMSI STATE AUTHD
50767807532 714011000643614 CONNECTED AVAILABLE
NAM
0
PERMANENT SUBSCRIBER DATA
SUD
CAT-10 DBSG-1 TSMO-0 OBR-2
OSB4-1 TS11-1 TS21-1 TS22-1
BS2G-1 BS3G-1 REDMCH-1 OFA-1
PWD-0000 EMLPP-1 DEMLPP-5 MEMLPP-5
OICK-24 TICK-11 CFU-1 BAOC-1
BOIC-1 BOIEXH-1 BAIC-1 BICRO-1
CAW-1 SOCFU-0 SOCB-1 SOCLIP-0
SODCF-0 SOSDCF-7 HOLD-1 MPTY-1
CLIP-1 RED-1
SCHAR-8-0
SUPPLEMENTARY SERVICE DATA
BSG
TS10
SS STATUS FNUM TIME
SADD
BAIC NOT ACTIVE
BAOC NOT ACTIVE
BSG
TS20
SS STATUS FNUM TIME
SADD
BAIC NOT ACTIVE
BAOC NOT ACTIVE
BSG
BS20
SS STATUS FNUM TIME
SADD
BAIC NOT ACTIVE
BAOC NOT ACTIVE
BSG
BS30
SS STATUS FNUM TIME
SADD
BAIC NOT ACTIVE
BAOC NOT ACTIVE
Script
Code :
BEGIN { RS="hgsdp" }
{ cat[1] = "OBO"
cat[2] = "OBR"
cat[3] = "OBI"
cat[4] = "TS21"
cat[5] = "BAOC"
}
{
if ($12 ~ /NOT/ ) printf "\n" substr ($1,16,8) "," "NOT_CONNECTED" ;
else printf "\n" substr ($1,16,8) "," $12
}
{
for (x = 1; x <= 5; x++)
if (match($0,cat[x])) printf "," substr($0, RSTART, RLENGTH+2)
else { printf "," cat[x]"-0" }
if (match($0,"OICK")) printf "," substr($0, RSTART, RLENGTH+3)
if (match($0,"TICK")) printf "," substr($0, RSTART, RLENGTH+3)
if (match($0,"PACKET.*END")) { A=substr($0, RSTART, RLENGTH)
while(match(A, "\n *[0-9]+ ")) {
V=substr(A, RSTART+1, RLENGTH-2)
sub(/^ */, ",",V)
printf V
A=substr(A,RSTART+RLENGTH+1)
}
}
}
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi! Is there a way to append column and row header to a file in awk script.
For example if I have
Jane F 39 manager
Carlos M 40 system administrator
Sam F 20 programmer
and I want it to be
# name gend age occup
1 Jane F 39 manager
2 Carlos M ... (4 Replies)
Discussion started by: FUTURE_EINSTEIN
4 Replies
2. Shell Programming and Scripting
Is it possible to remove redundant names in the 4th column?
input
cqWE 100 200 singapore;singapore
AZO 300 400 brazil;america;germany;ireland;germany
....
....
output
cqWE 100 200 singapore
AZO 300 400 brazil;america;germany;ireland (4 Replies)
Discussion started by: quincyjones
4 Replies
3. Shell Programming and Scripting
Experts Good day,
I have the following data, file1
BRAAGRP1
A2X
B2X
C2X
D2X
BRBGRP12
A3X
B3X
Z10
D09
BRC1GRP2
LO01 (4 Replies)
Discussion started by: rveri
4 Replies
4. UNIX for Dummies Questions & Answers
file with this content
awk 'NR==1 {print $4} && NR==2 {print $5}' file
The error is shown with syntax error; what can be done (4 Replies)
Discussion started by: cdfd123
4 Replies
5. Shell Programming and Scripting
Hi,
I have the following file,
chr1 100 200 20
chr1 201 300 22
chr1 220 345 23
chr1 230 456 33.5
chr1 243 567 90
chr1 345 600 20
chr1 430 619 21.78
chr1 870 910 112.3
chr1 914 920 12
chr1 930 999 13
My output would be
peak1 20 22 23 33.5 90
peak2 20 21.78 112.3 12 13
Here the... (3 Replies)
Discussion started by: jacobs.smith
3 Replies
6. Shell Programming and Scripting
Hi,
My input files is like this
axis1 0 1 10
axis2 0 1 5
axis1 1 2 -4
axis2 2 3 -3
axis1 3 4 5
axis2 3 4 -1
axis1 4 5 -6
axis2 4 5 1
Now, these are my following tasks
1. Print a first column for every two rows that has the same value followed by a string.
2. Match on the... (3 Replies)
Discussion started by: jacobs.smith
3 Replies
7. Shell Programming and Scripting
Dear All,
I have input :
SEG901 5173 9005 5740
SEG902 5227 5284
SEG903 5284 5346
SEG904 5346 9010
SEG905 5400 5456
SEG906 5456 5511
SEG907 5511 9011
SEG908 5572 9015
SEG909 5622 9020
SEG910 5678 5739
SEG911 5739 5796
SEG912 5796 9025 ... (3 Replies)
Discussion started by: attila
3 Replies
8. Shell Programming and Scripting
Hi..
I have data :
Report testing1 20180419 08:00
Report testing2 20180419 07:35
Report testing 20180419 08:01
Source = data1
Report testing4 20180419 08:05
Source = data1
Report testing5 20180419 08:10
Source = data2
Report testing6 20180419 08:01
Report testing7 20180419 08:19... (4 Replies)
Discussion started by: buncit8
4 Replies
9. Shell Programming and Scripting
Example:
I have files in below format
file 1:
zxc,133,joe@example.com
cst,222,xyz@example1.com
File 2 Contains:
hxd
hcd
jws
zxc
cst
File 1 has 50000 lines and file 2 has around 30000 lines :
Expected Output has to be :
hxd
hcd
jws (5 Replies)
Discussion started by: TestPractice
5 Replies
10. UNIX for Beginners Questions & Answers
Hi ,
Can anyone help me suggesting - how to do the below trick with awk
Input
120
130
140
210
310
410
645
729
800
Output
120 130 140 (6 Replies)
Discussion started by: Indra2011
6 Replies