Extract values only for certain tags


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Extract values only for certain tags
# 1  
Old 12-10-2014
Extract values only for certain tags

Hi

Please I need help on extracting values, of certain tags
Code:
MSISDN:

, and
Code:
IMSI:

in the following text file
Code:
entryDS: 1
nodeId: 11
MSISDN: 258827475309
IMSI: 643012111658984
NAM: 0                                                                
CDC: 41
IMEISV:: U3URIGF2hoc=
AUTHINFO: 0
TSMO: 0
CSP: 27
SUBSCSPVERS: 7
PDPCP: 11
SUBSPDPCPVERS: 5
RSA: 1
SUBSRSAVERS: 4
dn: IMSI=643012112814555,dc=imsi,ou=identities,dc=mcel
objectClass: alias
objectClass: IMSI
structuralObjectClass: alias
entryDS: 0
IMSI: 643012112814555
aliasedObjectName: mscId=bbbbbbbbbbbbbbbbb643012112814555,ou=multiSCs,dc=mcel
CAMP: 0
serv: CSPS
CSLOC: 5
VLRADD: 1925882200060
PSLOC: 0
SGSNNUM: 1925882200054
GSMMSRNMSCN:: AJFSiCIAYPA=
SCLOCSTATE: 6
SZONELOCSTATE: 6
PURGEDATECS:: DgsT
RVLRI: 0
RSGSNI: 0
GMSCADDRESS:: kVKIIgCQ9Q==
CSIVLRSUPP: 1
GSMMAPVERS: 3
GSMUEFEAT: 0
GSMDUALNUMSUP: 1
GPRSRELSUPP: 1
OBOPRI: 1
OBOPRE: 1
SCHAR:: BAA=
CAT: 10
DBSG: 1
OFA: 0
SOCB: 0
PWD: 0000
PWDC: 0
SOCFB: 0
SOCFNRC: 0
SOCFNRY: 0
SOCFU: 0
SODCF: 0
SOSDCF: 7
SOCLIP: 0
SOCLIR: 2
SOCOLP: 0
BS3G: 1
TS11: 1
TS21: 1
TS22: 1
CAW: 1
HOLD: 1
BAIC: 1
BAOC: 1
BICRO: 1
BOIC: 1
BOIEXH: 1
CFB: 1
CFNRC: 1
CFNRY: 1
CFU: 1
CLIP: 1
CLIR: 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
CAWBS30ST: 8
CFBBS30ST: 8
CFUBS30ST: 8
CFNRCBS30ST: 8
CFNRYBS30ST: 8
BAICBS30ST: 8
BAOCBS30ST: 8
BICROBS30ST: 8
BOICBS30ST: 8
BOIEXHBS30ST: 8
SMSCADD32:: kVKIIgAw8A==
SMSCEXPDATE32:: DgwF
MNRF: 1


dn: serv=Identities,mscId=bbbbbbbbbbbbbbbbb643012111658984,ou=multiSCs,dc=mcel
structuralObjectClass: CUDBService
objectClass: CUDBService
objectClass: mscIdentities
entryDS: 1
nodeId: 11
serv: Identities
CDC: 0
IMSI: 643012111658984
imsiMask: '0000000000010001'B
MSISDN: 258827475309
msisdnMask: '0000000000000001'B

I am trying to use either
Code:
sed

or
Code:
awk

, but with no success
This User Gave Thanks to fretagi For This Post:
# 2  
Old 12-10-2014
What awk and sed commands did you try?
# 3  
Old 12-10-2014
Hi!

I try the following to print only lines with capital M and capital I
Code:
sed -n '/^M\|^I/p' imsi

and to print me the lines with word "IMSI" by running
Code:
sed -n '/[IMSI]$/p' imsi

where
Code:
imsi

is the filename

in the first example the output was
Code:
objectClass:IMSI

and the second example, returned nothing
# 4  
Old 12-10-2014
Quote:
Originally Posted by fretagi
Hi!

I try the following to print only lines with capital M and capital I
Code:
sed -n '/^M\|^I/p' imsi

and to print me the lines with word "IMSI" by running
Code:
sed -n '/[IMSI]$/p' imsi

where
Code:
imsi

is the filename

in the first example the output was
Code:
objectClass:IMSI

and the second example, returned nothing
I would have expected that output from your second example and no output from your first example. The second example should print any line whose last character on the line is I, M, or S.

To print only lines whose first character is an M or an I, try:
Code:
sed -n '/^[MI]/p' imsi

and to print lines containing IMSI, try:
Code:
sed -n '/IMSI/p' imsi

# 5  
Old 12-10-2014
your last command worked fine, so how can I use your last command to also include the word
Code:
MSISDN

# 6  
Old 12-10-2014
Code:
sed -n -e '/IMSI/p' -e '/MSISDN/p' imsi

This User Gave Thanks to Don Cragun For This Post:
# 7  
Old 12-10-2014
Thank you very much
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Extract multiple values into corresponding variables

Here is my input # MANIFEST.MF Manifest-Version: 1.0 Build-Jdk: 1.6.0 Built-By: CM_TEAM Build_SvnRev: 662789 Build_Number: 13.0.0.0-JDK8 Build_Date: Wed 04/05/2017-20:48:19.17 Archiver-Version: Plexus Archiver Created-By: Apache Maven 3.1.0 Here is the expected output:... (4 Replies)
Discussion started by: kchinnam
4 Replies

2. Shell Programming and Scripting

Extract values in a line using awk

hello all, I need your help in extracting values of some parameter within a line using awk. for example: i have the below line available in a file and i want to extract the values of only CustomerId, s_PackageId and s_HZINumbers in order the result to be as ... (13 Replies)
Discussion started by: nael_najib
13 Replies

3. Shell Programming and Scripting

Extract values

hi I have a line as given below. I need to match "COLUMN_NAME" and get the every third value ie words in between quotes completely (' ') Sample Input - COLUMN_NAME Like '%value%' Or COLUMN_NAME Like '%value%' Or COLUMN_NAME Like '%value value%' Or COLUMN_NAME Like '%value%' OR... (5 Replies)
Discussion started by: Prashanth B
5 Replies

4. Shell Programming and Scripting

Is it possible to extract these values from the output

Hi, I would like to search based of "java" and "-Dplatform.home=" and store these two values in bash variables. ps -xef | grep <pid> wlsuser 15160 15144 0 Feb 20 ? 17:27 /app1/jdk150_07/bin/IA64N/java -server -Xms1536m -Dplatform.home=/app1/bea/weblogic92... (13 Replies)
Discussion started by: mohtashims
13 Replies

5. Shell Programming and Scripting

extract key values

I am parsing a log with key values spread all over in the following fashion: TEST 1 SCHEME 12 SET EMPTY VARLEN SET TEST 1201 PARAM1 EMTY PARAM2 SET SCHEME 12 REFRESH TEST 8 I need to extract test number, my result should be 1 1201 8 I use awk for processing this log and use... (4 Replies)
Discussion started by: migurus
4 Replies

6. Shell Programming and Scripting

to extract specific values twice in a file

Hi Friends, I have a file with the following values.. xyz.txt,12345.xml abc.txt,04567.xml cde.txt,12134.xml I would like to extract all the 2nd column values twice as shown in the example like 12345,12345.xml 04567,04567.xml 12134,12134.xml Please advice!! In the formus one of... (7 Replies)
Discussion started by: techmoris
7 Replies

7. Shell Programming and Scripting

Extract Values from CSV

Hi, I need to extract values from a CSV file based on some conditions as explained below: File format details: 1. each set starts with AAA only 2. number of columns is fixed 3. number of rows per set may vary (as they are having different CCC rows) Now, i need to extract 3rd column of... (3 Replies)
Discussion started by: prvnrk
3 Replies

8. Shell Programming and Scripting

Extract XML Element Values

I have a rather large file with XML-style content. Each line contains one full XML entry. For example: 1:<Message><DNIS>1234</DNIS><UCID>3456</UCID><TransferGroup>XYZXYZ</TransferGroup></Message> 2:<Message><DNIS>9999</DNIS><UCID>2584</UCID><TransferGroup>ABCABC</TransferGroup></Message>... (1 Reply)
Discussion started by: sharpi03
1 Replies

9. Shell Programming and Scripting

how to extract values b/w two delimiters

Hi, Please help me to extrat values b/w two delimiters. $ echo $abc i want to extract the value 12345 b/w %. (5 Replies)
Discussion started by: tsaravanan
5 Replies

10. Shell Programming and Scripting

Extract values from log file

I would like to write a shell script that will parse through a file similar to the sample below. The data in the file is redirected from rsync into a log file. I would like to call a shell script to parse through and pick out the number beside the percent sign inside the parentheses in the last... (5 Replies)
Discussion started by: wdympcf
5 Replies
Login or Register to Ask a Question

Featured Tech Videos