Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Shell script to extract data in a file Post 302991700 by gillesi on Wednesday 15th of February 2017 01:57:12 PM
Old 02-15-2017
Let's say this is the input, 2(actually they are 4milion) blocks of line.
(dn:serv=...) begining of a block and space the end of block.
In each block, i want to extract only the MSISDN,IMSI,NAM,TS11,21,22,BAIC,APNID,OBO,OBI then for each block the expected values should be in the same line separated by semi colon or colon.


Code:
dn:serv=CSPS,mscId=00015640ccf345a7914718d3d3eff6f6,ou=multiSCs,dc=mtncg
structuralObjectClass: CP1
objectClass: CP1
objectClass: CUDBServiceAuxiliary
objectClass: CP2
objectClass: CP3
objectClass: CP4
objectClass: CP5
objectClass: CP6
objectClass: CP7
objectClass: CP8
objectClass: CP9
objectClass: CPA
objectClass: CPB
objectClass: CPC
objectClass: CPD
objectClass: CPE
objectClass: CPF
objectClass: CPG
objectClass: CPH
objectClass: CPI
objectClass: CPJ
objectClass: CPK
objectClass: CPL
objectClass: CPM
objectClass: CPM1
objectClass: CPM2
objectClass: CPM3
objectClass: CPM4
objectClass: CPZ
objectClass: CP04s
objectClass: CP0A
objectClass: CP11
entryDS: 1
nodeId: 1
createTimestamp: 20170104222519Z
modifyTimestamp: 20170113111014Z
MSISDN: 242064493944
IMSI: 629100113334650
NAM: 1
CDC: 6
CSP: 6
SUBSCSPVERS: 3
PDPCP: 12
SUBSPDPCPVERS: 1
RSA: 3
SUBSRSAVERS: 10
APNID1: 2
APNVERS1: 1
APNID2: 1
APNVERS2: 1
APNID3: 0
APNVERS3: 1
EQOSIDV1:: AAAC
EQOSIDV2:: AAAC
EQOSIDV3:: AAAC
serv: CSPS
CSLOC: 2
RVLRI: 0
RSGSNI: 0
GSMUEFEAT: 0
OBO: 1
OBI: 1
MCA: 1
CAT: 10
DBSG: 1
OFA: 0
SOCB: 1
PWD: 0000
PWDC: 0
SOCFB: 0
SOCFNRC: 0
SOCFNRY: 0
SOCFU: 0
SODCF: 0
SOSDCF: 7
SOCLIP: 0
SOCLIR: 0
SOCOLP: 0
BS26: 1
BS3G: 1
TS11: 1
TS21: 1
TS22: 1
TS62: 1
CAW: 1
HOLD: 1
MPTY: 1
OICK: 10
BAIC: 1
BAOC: 1
BICRO: 1
BOIC: 1
BOIEXH: 1
CFB: 1
CFNRC: 1
CFNRY: 1
CFU: 1
CLIP: 1
CAWTS10ST: 8
CFBTS10ST: 8
CFUTS10ST: 8
CFNRCTS10ST: 8
CFNRYTS10ST: 8
BAICTS10ST: 8
BAOCTS10ST: 8
BICROTS10ST: 8
BOICTS10ST: 8
BOIEXHTS10ST: 8
BAICTS20ST: 8
BAOCTS20ST: 8
BICROTS20ST: 8
BOICTS20ST: 8
BOIEXHTS20ST: 8
CAWTS60ST: 8
CFBTS60ST: 8
CFUTS60ST: 8
CFNRCTS60ST: 8
CFNRYTS60ST: 8
BAICTS60ST: 8
BAOCTS60ST: 8
BICROTS60ST: 8
BOICTS60ST: 8
BOIEXHTS60ST: 8
CAWBS30ST: 8
CFBBS30ST: 8
CFUBS30ST: 8
CFNRCBS30ST: 8
CFNRYBS30ST: 8
BAICBS30ST: 8
BAOCBS30ST: 8
BICROBS30ST: 8
BOICBS30ST: 8
BOIEXHBS30ST: 8
CAWBS20ST: 8
CFBBS20ST: 8
CFUBS20ST: 8
CFNRCBS20ST: 8
CFNRYBS20ST: 8
BAICBS20ST: 8
BAOCBS20ST: 8
BICROBS20ST: 8
BOICBS20ST: 8
BOIEXHBS20ST: 8
EQOSID1: 0
PDPTYPE1: 0
VPAA1: 0
EQOSID2: 0
PDPTYPE2: 0
VPAA2: 0
EQOSID3: 0
PDPTYPE3: 0
VPAA3: 0

dn: serv=CSPS,mscId=0001b7b4ad4d44bbb73484e858270eb3,ou=multiSCs,dc=mtncg
structuralObjectClass: CP1
objectClass: CP1
objectClass: CUDBServiceAuxiliary
objectClass: CP2
objectClass: CP3
objectClass: CP4
objectClass: CP5
objectClass: CP6
objectClass: CP7
objectClass: CP8
objectClass: CP9
objectClass: CPA
objectClass: CPB
objectClass: CPC
objectClass: CPD
objectClass: CPE
objectClass: CPF
objectClass: CPG
objectClass: CPH
objectClass: CPI
objectClass: CPJ
objectClass: CPK
objectClass: CPL
objectClass: CPM
objectClass: CPM1
objectClass: CPM2
objectClass: CPM3
objectClass: CPM4
objectClass: CPZ
objectClass: CP04s
objectClass: CP0A
objectClass: CP11
entryDS: 1
nodeId: 1
createTimestamp: 20170119174955Z
modifyTimestamp: 20170119174956Z
MSISDN: 242068626345
IMSI: 629100114187228
NAM: 0
CDC: 3
CSP: 6
SUBSCSPVERS: 3
PDPCP: 12
SUBSPDPCPVERS: 1
RSA: 3
SUBSRSAVERS: 10
APNID1: 2
APNVERS1: 1
APNID2: 1
APNVERS2: 1
APNID3: 0
APNVERS3: 1
EQOSIDV1:: AAAC
EQOSIDV2:: AAAC
EQOSIDV3:: AAAC
serv: CSPS
CSLOC: 2
PSLOC: 2
RVLRI: 0
RSGSNI: 0
GSMUEFEAT: 0
MCA: 1
CAT: 10
DBSG: 1
OFA: 0
SOCB: 1
PWD: 0000
PWDC: 0
SOCFB: 0
SOCFNRC: 0
SOCFNRY: 0
SOCFU: 0
SODCF: 0
SOSDCF: 7
SOCLIP: 0
SOCLIR: 0
SOCOLP: 0
BS26: 1
BS3G: 1
TS11: 1
TS21: 1
TS22: 1
TS62: 1
CAW: 1
HOLD: 1
MPTY: 1
OICK: 10
BAIC: 1
BAOC: 1
BICRO: 1
BOIC: 1
BOIEXH: 1
CFB: 1
CFNRC: 1
CFNRY: 1
CFU: 1
CLIP: 1
CAWTS10ST: 8
CFBTS10ST: 8
CFUTS10ST: 8
CFNRCTS10ST: 8
CFNRYTS10ST: 8
BAICTS10ST: 8
BAOCTS10ST: 8
BICROTS10ST: 8
BOICTS10ST: 8
BOIEXHTS10ST: 8
BAICTS20ST: 8
BAOCTS20ST: 8
BICROTS20ST: 8
BOICTS20ST: 8
BOIEXHTS20ST: 8
CAWTS60ST: 8
CFBTS60ST: 8
CFUTS60ST: 8
CFNRCTS60ST: 8
CFNRYTS60ST: 8
BAICTS60ST: 8
BAOCTS60ST: 8
BICROTS60ST: 8
BOICTS60ST: 8
BOIEXHTS60ST: 8
CAWBS30ST: 8
CFBBS30ST: 8
CFUBS30ST: 8
CFNRCBS30ST: 8
CFNRYBS30ST: 8
BAICBS30ST: 8
BAOCBS30ST: 8
BICROBS30ST: 8
BOICBS30ST: 8
BOIEXHBS30ST: 8
CAWBS20ST: 8
CFBBS20ST: 8
CFUBS20ST: 8
CFNRCBS20ST: 8
CFNRYBS20ST: 8
BAICBS20ST: 8
BAOCBS20ST: 8
BICROBS20ST: 8
BOICBS20ST: 8
BOIEXHBS20ST: 8
EQOSID1: 0
PDPTYPE1: 0
VPAA1: 0
EQOSID2: 0
PDPTYPE2: 0
VPAA2: 0
EQOSID3: 0
PDPTYPE3: 0
VPAA3: 0


Moderator's Comments:
Mod Comment Please use CODE tags as required by forum rules!

Last edited by RudiC; 02-15-2017 at 03:31 PM.. Reason: Added CODE tags.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to extract data using UNIX shell script?

Hello All, I am starting with UNIX. Any help is highly appreciated. How to extract data using UNIX shell script? And how do you export data using UNIX shell scripts into Microsoft Excel format? Thank you. (3 Replies)
Discussion started by: desiondarun
3 Replies

2. Shell Programming and Scripting

extract data from xml- shell script using awk

Hi, This is the xml file that i have. - <front-servlet platform="WAS4.0" request-retriever="SiteMinder-aware" configuration-rescan-interval="60000"> <concurrency-throttle maximum-concurrency="50" redirect-page="/jsp/defaulterror.jsp" /> - <loggers> <instrumentation... (5 Replies)
Discussion started by: nishana
5 Replies

3. Shell Programming and Scripting

shell-script which extract data from log file

give me a shell-script which extract data from log file on a server by giving date and time as input (for both start time and end time) and it will give the logs generated during the given time as output. (4 Replies)
Discussion started by: abhishek27
4 Replies

4. Shell Programming and Scripting

Help with shell script to extract data from XML file

Hello Scripting Gurus, I need help with extracting data from the XML file using shell script. The data is in a large XML and I need to extract the id values of all completedworkflows. Here is a sample of it. Input and output data is also in the attached text files. <wfregistry>... (5 Replies)
Discussion started by: yajaykumar
5 Replies

5. Shell Programming and Scripting

Need shell script to extract data from oracle database

shell script (4 Replies)
Discussion started by: frns5
4 Replies

6. Shell Programming and Scripting

need a shell script to extract data from a log file.

If I have a log like : Mon Jul 19 05:07:34 2010; TCP; eth3; 52 bytes; from abc to def Mon Jul 19 05:07:35 2010; UDP; eth3; 46 bytes; from aaa to bbb Mon Jul 19 05:07:35 2010; TCP; eth3; 52 bytes; from def to ghi I will need an output like this : Time abc to def... (1 Reply)
Discussion started by: hitha87
1 Replies

7. Shell Programming and Scripting

regular expression with shell script to extract data out of a text file

hi i am trying to extract some specific data out of a text file using regular expressions with shell script that is using a multiline grep .. and the tool i am using is pcregrep so that i can get compatibility with perl's regular expressions for a sample data like this, i am trying to grab... (6 Replies)
Discussion started by: vemkiran
6 Replies

8. UNIX for Dummies Questions & Answers

Shell script to extract data from csv file based on certain conditions

Hi Guys, I am new to shell script.I need your help to write a shell script. I need to write a shell script to extract data from a .csv file where columns are ',' separated. The file has 5 columns having values say column 1,column 2.....column 5 as below along with their valuesm.... (1 Reply)
Discussion started by: Vivekit82
1 Replies

9. UNIX for Dummies Questions & Answers

Shell script to extract data from csv file

Hi Guys, I am new to shell script.I need your help to write a shell script. I need to write a shell script to extract data from a .csv file where columns are ',' separated. The file has 7 columns having values say column 1,column 2.....column 7 as below along with their values. Name, Address,... (7 Replies)
Discussion started by: Vivekit82
7 Replies

10. Shell Programming and Scripting

Shell script to extract data from csv file

Hi everyone, I have a csv file which has data with different heading and column names as below. Static Data Ingested ,,,,,,,,,,,,Known Explained Rejections Column_1,column_2,Column_3,Column_4,,Column_6,Column_7,,% Column_8,,Column_9 ,Column_10 ,... (14 Replies)
Discussion started by: Vivekit82
14 Replies
All times are GMT -4. The time now is 09:12 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy