Sponsored Content
Top Forums Shell Programming and Scripting Print string after the word match Post 302873015 by justbow on Monday 11th of November 2013 02:54:27 AM
Old 11-11-2013
Print string after the word match

Hi,

I have the logs :
Code:
cat logsx.txt

744906,{"reportingGroups":[{"absoluteAccumulated":{"bidirVol":1442755910,"expiryDate":{"volume":"23-11-2013T02:00:22"},"previousExpiryDate":{"time":"02-10-2013T06:14:21","volume":"23-10-2013T02:00:10"},"resetPeriod":{"volume":"monthly day 23 02:00"}},"selected":"no","subsGName":"Matrix_1GB_16","subscriptionDate":"02-10-2013T06:14:21","validityTime":1178681},{"absoluteAccumulated":{"bidirVol":102098178,"previousExpiryDate":{"time":"09-11-2013T10:53:00","volume":"09-11-2013T10:53:00"}},"restartInfo":"09-11-2013T10:53","selected":"yes","subsGName":"1GB7D0800","subscriptionDate":"09-11-2013T10:53:00","validityTime":0}],"version":"2.0"}
678874,{"reportingGroups":[{"absoluteAccumulated":{"bidirVol":1318102561,"expiryDate":{"volume":"23-11-2013T02:00:20"},"previousExpiryDate":{"time":"02-10-2013T03:12:17","volume":"23-10-2013T02:00:02"},"resetPeriod":{"volume":"monthly day 23 02:00"}},"selected":"no","subsGName":"Matrix_5GB_16","subscriptionDate":"02-10-2013T03:12:17","validityTime":1051965},{"absoluteAccumulated":{"bidirVol":20004753,"previousExpiryDate":{"time":"10-11-2013T21:54:00","volume":"10-11-2013T21:54:00"}},"restartInfo":"10-11-2013T21:54","selected":"yes","subsGName":"1GB7D0800","subscriptionDate":"10-11-2013T21:54:00","validityTime":0}],"version":"2.0"}
193571,{"reportingGroups":[{"absoluteAccumulated":{"bidirVol":777438189,"expiryDate":{"volume":"08-12-2013T02:00:52"},"previousExpiryDate":{"time":"06-10-2013T18:23:34","volume":"08-11-2013T02:00:17"},"resetPeriod":{"volume":"monthly day 8 02:00"}},"selected":"yes","subsGName":"Go28_8","subscriptionDate":"06-10-2013T18:23:34","validityTime":2329299},{"absoluteAccumulated":{"bidirVol":1078862229,"previousExpiryDate":{"time":"01-11-2013T18:19:00","volume":"01-11-2013T18:19:00"}},"restartInfo":"01-11-2013T18:19","selected":"no","subsGName":"1GB7D0800","subscriptionDate":"01-11-2013T18:19:00","validityTime":0}],"version":"2.0"}
811537,{"reportingGroups":[{"absoluteAccumulated":{"bidirVol":204352282,"expiryDate":{"volume":"23-11-2013T02:00:39"},"previousExpiryDate":{"time":"02-10-2013T09:45:22","volume":"23-10-2013T02:00:06"},"resetPeriod":{"volume":"monthly day 23 02:00"}},"selected":"yes","subsGName":"Matrix_2GB_16","subscriptionDate":"02-10-2013T09:45:22","validityTime":995066}],"version":"2.0"}
772024,{"reportingGroups":[{"absoluteAccumulated":{"bidirVol":32687329,"expiryDate":{"volume":"23-11-2013T02:00:15"},"previousExpiryDate":{"time":"02-10-2013T16:42:02","volume":"23-10-2013T02:00:57"},"resetPeriod":{"volume":"monthly day 23 02:00"}},"selected":"yes","subsGName":"Matrix_5GB_16","subscriptionDate":"02-10-2013T16:42:02","validityTime":1241216}],"version":"2.0"}
732724,{"reportingGroups":[{"absoluteAccumulated":{"bidirVol":109926510,"expiryDate":{"volume":"23-11-2013T02:00:03"},"previousExpiryDate":{"time":"02-10-2013T03:05:19","volume":"23-10-2013T02:00:49"},"resetPeriod":{"volume":"monthly day 23 02:00"}},"selected":"no","subsGName":"Matrix_5GB_16","subscriptionDate":"02-10-2013T03:05:19","validityTime":994852}],"version":"2.0"}
983366,{"reportingGroups":[{"absoluteAccumulated":{"bidirVol":86051166,"expiryDate":{"volume":"23-10-2013T02:00:25"},"previousExpiryDate":{"time":"02-10-2013T03:07:52","volume":"02-10-2013T03:07:52"},"resetPeriod":{"volume":"monthly day 23 02:00"}},"selected":"yes","subsGName":"Matrix_5GB_16","subscriptionDate":"02-10-2013T03:07:52","validityTime":223910}],"version":"2.0"}

I want the results will be like this:

Code:
number,bidirVol1,subsGName1,bidirVol2,subsGName2
744906,Matrix_1GB_16,1442755910,102098178,1GB7D0800
678874,Matrix_5GB_16,1318102561,20004753,1GB7D0800
193571,Go28_8,777438189,1078862229,1GB7D0800
811537,Matrix_2GB_16,204352282
772024,Matrix_5GB_16,32687329
732724,Matrix_5GB_16,109926510
983366,Matrix_5GB_16,86051166

Anybody can help ?
Thanks

Last edited by justbow; 11-11-2013 at 04:02 AM.. Reason: word wrong
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

exact string match in a word

Hi all, Is anyone able to help with the following query? I have an input file with several lines of words, e.g. "hellolaylahello" "hellohellohellolayla" I want to search for the exact string "hello" in each line and display: 2 "hellolaylahello" 3 "hellohellohellolayla" I... (11 Replies)
Discussion started by: dr_sabz
11 Replies

2. Shell Programming and Scripting

Search word in a line and print earlier pattern match

Hi All, I have almost 1000+ files and I want to search specific pattern. Looking forwarded your input. Search for: word1.word2 (Which procedure contain this word, I need procedure name in output. Expected output: procedure test1 procedure test2 procedure test3 procedure test4 ... (7 Replies)
Discussion started by: susau_79
7 Replies

3. Shell Programming and Scripting

Print all the words after a match word

Hi, I want to print all words till the last word after the match of "ERROR" word. For e.g. I'll get an sqlplus error with e.g. 1 $ ./calltest_fn.ksh var test_var:=test_fn1; calltest_fn.ksh file1 file2 file3 ERROR at line 4: ORA-06550: line 4, column 11: PLS-00201: identifier... (5 Replies)
Discussion started by: dips_ag
5 Replies

4. Shell Programming and Scripting

exact string match ; search and print match

I am trying to match a pattern exactly in a shell script. I have tried two methods awk '/\<mpath${CURR_MP}\>/{print $1 $2}' multipath perl -ne '/\bmpath${CURR_MP}\b/ and print' /var/tmp/multipath Both these methods require that I use the escape character. I am guessing that is why... (8 Replies)
Discussion started by: bash_in_my_head
8 Replies

5. Shell Programming and Scripting

print word after pattern match in two instances

i have a file like below. how can i printout the digits followed by the pattern -bwout and -bwin. say i run the script by entering line number 145 (the fourth line), then the o/p should be like 5000000 1024000 8 test1 -ipprot erp -ppsout 500 -ppsin 500 -bwout 300000 -bwin 300000 -statsdevice... (7 Replies)
Discussion started by: sb245
7 Replies

6. Shell Programming and Scripting

find a word and print n lines before and after the match

how to find a word and print n lines before and after the match until a blank line is encounterd (14 Replies)
Discussion started by: chidori
14 Replies

7. Shell Programming and Scripting

How to print everything after a string match

Hi all, I'm trying to do some work on the authorized_keys file to do a check if there's any information after the hash key.. At the end of the hash key's in the file, there can be an = or == Is there a way to check if anything exists after these equals and if so print it out or else print... (2 Replies)
Discussion started by: Jazmania
2 Replies

8. Shell Programming and Scripting

Print a word after a match

Hi all, I have the below line: 08 03 * * 1-5 XXXXXXXXXXXXX -ENVI LDNFOUAT10 -EXE xxxxxxxx -CONFIG \${xxxxx} -SUBCLASS RESET -START -EXTRAAPPARGS \" -env 38LDNFOUAT10 \" >> /tmp/SRRC_xxxxxxx_start.log.`/usr/bin/date +\%Y\%m\%d` 2>&1 I want to print just one word after the string "-env", in... (7 Replies)
Discussion started by: Cvg
7 Replies

9. Shell Programming and Scripting

How to match the first word and print only that line in UNIX?

Below is the file DISK-A 109063.2 49 31 40.79 DISK-B 110058.5 49 44 57.07 DISK-c 4402.4 2 1 2.14 from the file, i want to search for 'DISK-A' and print only that line with the first word matching to DISK-A and the output should skip DISK-A. Desired Output: (If i'm... (2 Replies)
Discussion started by: web2moha
2 Replies

10. Shell Programming and Scripting

Need to print the next word from the same line based on grep string condtion match.

I need to fetch particular string from log file based on grep condition match. Actual requirement is need to print the next word from the same line based on grep string condtion match. File :Java.lanag.xyz......File copied completed : abc.txt Ouput :abc.txt I have used below... (5 Replies)
Discussion started by: siva83
5 Replies
All times are GMT -4. The time now is 12:28 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy