Grep 2 same strings in a same line??


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Grep 2 same strings in a same line??
# 1  
Old 03-06-2013
Grep 2 same strings in a same line??

I have this code

Code:
Code:
 TrackingId:1362412470675;MSISDN:; INFO  [ResponseQueueDispatcher.run:32] - [] number of clietns:3:Received response is: EMSResponse [responseType=NOTIFICATION, serviceId=idBamboo, additionalParameters={NOTIFICATION_TYPE=BAMBOO, IS_CHERRY=1, opid=IDEA, DEVICE_PLATFORM=S30}, confirmedPurchaseResponse=null, msgid=ISRN, preparePurchaseResponse=null, processingResult=ProcessingResult [errorMessage=null, success=true, processResponse=null, errorMessageResource=null], protocolVersion=5, purchaseOptions=null, serviceData=ServiceData [messageId=ufbsE12v, screens=[Screen [actions=[], screenData=CanvasData [canvasComponents=[CanvasComponent [content=null, type=TEXT, markers={}, contentLangCode=en , contentResource=MessageResource[text=null, textId=bamboo_msg, placeholders=null, resolvable=true, textLangCode=en]]], title=null, titleResource=MessageResource[text=null, textId=bamboo_msg_title, placeholders=null, resolvable=true, textLangCode=en]], screenType=null]], serviceId=idBamboo, serviceStatus=STATUS_GET_ONCE, variables=[]], sourceMsisdn=null, targetInbox=NLT_INBOX, destinations=[Destination [deviceId=03551890591, mints=918958266637, transactionId=1362412, clientSoftwareVersion=5], Destination [deviceId=0355212052568245, mints=918347032859, transactionId=1362412469578, clientSoftwareVersion=5], Destination [deviceId=0355503058037783, mints=9186083, transactionId=1362412469853, c

I'm always getting the word mints in d same line for more than 1 time.

when i'm trying to grep , m not gettin d 2nd mints in d same line....

Actually m trying to get number after mints...

---------- Post updated at 04:12 PM ---------- Previous update was at 03:58 PM ----------

m looking for the 12 digit number after every mints in d line..
# 2  
Old 03-06-2013
Pls post , sample output you are expecting from the input.
# 3  
Old 03-06-2013
Code:
awk -F, 'NR>1 {print "mints="$1}' RS="mints=" infile
mints=918958266637
mints=918347032859
mints=9186083

You don't say anything on how you like the output.
Code:
awk -F, 'NR>1 {printf "%s,",$1} END {print ""} ' RS="mints="
918958266637,918347032859,9186083,

# 4  
Old 03-06-2013
Perl:
Code:
perl -lane 'while (m/\bmints=(\d+)/g){print $1}' infile

# 5  
Old 03-06-2013
i got it

grep -o "mints=............" filename

thank you all of you Smilie
# 6  
Old 03-06-2013
Not optimal. This may give
Code:
mints=53653465
mints=544, trans
mints=45454, tra

# 7  
Old 03-06-2013
Code:
grep -o "mints=[0-9][0-9]*,"  file_name

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Grep: Retrieve two strings from one file to find them anyone on line in another file

I am having trouble matching *two* strings from one file anywhere in a line of a second file, and could use some help getting this figured out. My preference would be to use grep for this because I would like to take advantage of its -A option. The latter is due to the fact that I would like both... (2 Replies)
Discussion started by: jvoot
2 Replies

2. UNIX for Beginners Questions & Answers

Use strings from nth field from one file to match strings in entire line in another file, awk

I cannot seem to get what should be a simple awk one-liner to work correctly and cannot figure out why. I would like to use patterns from a specific field in one file as regex to search for matching strings in the entire line ($0) of another file. I would like to output the lines of File2 which... (1 Reply)
Discussion started by: jvoot
1 Replies

3. Shell Programming and Scripting

awk or sed or grep filter a line and/or between strings

Hi, I have multiple files on a directory with the following content: blahblah blahblah hostname server1 blahblah blahblah ---BEGIN--- aaa bbb ccc ddd ---END--- blahblah blahblah blahblah I would like to filter all the files with awk or sed or something else so I can get below... (6 Replies)
Discussion started by: bayupw
6 Replies

4. Shell Programming and Scripting

Grep for strings

Hi, Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.94 Safari/537.36 How can I grep for the strings chrome and safari from a file, and if chrome print Chrome/40.0.2214.94 to a file and also count the number of times chrome is found? ... (4 Replies)
Discussion started by: cyberfrog
4 Replies

5. UNIX for Dummies Questions & Answers

Grep help (match two strings one line)

Hello, Here I have some grep command which is not working correctly: cat file1.txt: apples Date: Sun, 24 Feb 2013 8:14:06 -0800 peaches melons cherry sky cloud green purple yellow cat file2.txt: apples Date peaches melons 0800 cherry sky cloud green purple black (2 Replies)
Discussion started by: holyearth
2 Replies

6. Shell Programming and Scripting

Can't grep multiple strings

I have a script that periodically checks the Apache error_log to search for a specific error that causes it to hand and, if found, it restarts the service. I recently found another error that forces it to hand and won't serve pages until it is reset. What I'm trying to do is to get the script to... (3 Replies)
Discussion started by: cfjohnsn
3 Replies

7. Shell Programming and Scripting

grep a string and print strings on that line

i have a file like below ABS 12234 A C 12G CFY 23865 A C 34D i want to grep "A C" then print ABS 12G 12234 CFY 34D 23865 Thanks! (4 Replies)
Discussion started by: kingpeejay
4 Replies

8. Shell Programming and Scripting

grep two strings in a file..

Hello All, I have a big file about 1000 lines. Now i am trying to grep a particular string and printing the lines from the string. say for example in 500th line i have the date as "Mon Wed 14 20:15:24 2010". now i in my case i need to grep the combination of the strings "Mon Wed 14" and the... (7 Replies)
Discussion started by: intiraju
7 Replies

9. Shell Programming and Scripting

Grep Multiple Strings

Hi, Can any one pelase tell me how to grep multiple strings from multiple files in a singel folder? grep -E "string1|string2|string3|string4|string..." its taking lots of time.. can any please tell me fast grep??? URGENT (10 Replies)
Discussion started by: durgaprasad
10 Replies

10. Shell Programming and Scripting

want to grep only strings in a file?

Hai, Just want to print only alphanumeric in a file ex:- fdsdsklf#@^%$#hf output:- fdsdsklfhf plz, help me:o (5 Replies)
Discussion started by: balan_mca
5 Replies
Login or Register to Ask a Question