How to grouping time and based on value with multiple pattern?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to grouping time and based on value with multiple pattern?
# 1  
Old 07-19-2019
How to grouping time and based on value with multiple pattern?

Hi All,

need help...


I have some log below :
Code:
[2019-07-18T01:08:41+0700][AsyncHttpClient-3-9][ERROR][test.system.interfaces.paybill.service.impl.DefaultPayBillViewService] ### {"request_id":"e8395eb0-a8bd-11e9-b77b-d507ea5312aa","message":"when inquiry paybill 628524871 prevalidation cause : Invalid Transaction"}
[2019-07-18T01:09:39+0700][AsyncHttpClient-3-30][ERROR][test.system.interfaces.paybill.service.impl.DefaultPayBillViewService] ### {"request_id":"043f2310-a8be-11e9-b57b-f9c7344998d7","message":"when inquiry paybill 62821615 prevalidation cause : Invalid Transaction"}
[2019-07-18T01:14:31+0700][AsyncHttpClient-3-6][ERROR][test.system.interfaces.paybill.service.impl.DefaultPayBillViewService] ### {"request_id":"b90c3b70-a8be-11e9-b77b-d507ea5312aa","message":"when inquiry paybill 62822535 prevalidation cause : Invalid Transaction"}
[2019-07-18T01:08:41+0700][AsyncHttpClient-3-9][ERROR][test.system.interfaces.paybill.service.impl.DefaultPayBillViewService] ### {"request_id":"e8395eb0-a8bd-11e9-b77b-d507ea5312aa","message":"when inquiry paybill 62852487 prevalidation cause : Internal Error"}
[2019-07-18T01:09:39+0700][AsyncHttpClient-3-30][ERROR][test.system.interfaces.paybill.service.impl.DefaultPayBillViewService] ### {"request_id":"043f2310-a8be-11e9-b57b-f9c7344998d7","message":"when inquiry paybill 62821615 prevalidation cause : Error"}
[2019-07-18T01:14:31+0700][AsyncHttpClient-3-6][ERROR][test.system.interfaces.paybill.service.impl.DefaultPayBillViewService] ### {"request_id":"b90c3b70-a8be-11e9-b77b-d507ea5312aa","message":"when inquiry paybill 62822535 prevalidation cause : Insufficient balance"}

and want grouping by time ( minutes ) and value , and expected result like below :
Code:
2019-07-18T01:08  Invalid Transaction 3
2019-07-18T01:08  Error 2
2019-07-18T01:08  Insufficient balance 1



need help ...


Thanks
hadi



Moderator's Comments:
Mod Comment
Please wrap all code, files, input & output/errors in CODE tags.
It makes it easier to read and preserves multiple spaces for indentinf or fixed-width data.

Last edited by rbatte1; 07-19-2019 at 09:26 AM..
# 2  
Old 07-19-2019
Try
Code:
awk -F: '{sub (/\[/, "", $1); sub (/"}/, "", $NF); CNT[$1 ":" $2 " " $NF]++} END {for (c in CNT) print c, CNT[c]}' file
2019-07-18T01:14  Insufficient balance 1
2019-07-18T01:09  Error 1
2019-07-18T01:14  Invalid Transaction 1
2019-07-18T01:09  Invalid Transaction 1
2019-07-18T01:08  Invalid Transaction 1
2019-07-18T01:08  Internal Error 1

Your expected result can't be produced as there are no two identical time/value pairs in your sampe file.
This User Gave Thanks to RudiC For This Post:
# 3  
Old 07-20-2019
Hi rudic


thanks for your reply...its works
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Concatenation of multiple files based on file pattern

Hi, I have the following reports that get generated every 1 hour and this is my requirement: 1. 5 reports get generated every hour with the names "Report.Dddmmyy.Thhmiss.CTLR" "Report.Dddmmyy.Thhmiss.ACCD" "Report.Dddmmyy.Thhmiss.BCCD" "Report.Dddmmyy.Thhmiss.CCCD"... (1 Reply)
Discussion started by: Jesshelle David
1 Replies

2. UNIX for Beginners Questions & Answers

Consternation of multiple file names based on naming pattern

Hi, I have the following reports that get generated every 1 hour and this is my requirement: 1. 5 reports get generated every hour with the names "Report.Dddmmyy.Thhmiss.CTLR" "Report.Dddmmyy.Thhmiss.ACCD" "Report.Dddmmyy.Thhmiss.BCCD" "Report.Dddmmyy.Thhmiss.CCCD"... (1 Reply)
Discussion started by: Jesshelle David
1 Replies

3. Shell Programming and Scripting

Split a text file into multiple pages based on pattern

Hi, I have a text file (attached the sample). I have also, attached the way the way the files need to be split. We get this file, that will either have 24 Jurisdictions, or will miss some and retain some. Like in the attached sample file, there are only Jurisdictions 03,11,14,15, 20 and 30.... (3 Replies)
Discussion started by: ebsus
3 Replies

4. Shell Programming and Scripting

Multiple File Rename based on pattern - one line

All, I wanted to copy the files From: Daily_XYZ_TEST_1.csv Daily_XYZ_TEST_2.csv Daily_XYZ_TEST_3.csv Daily_XYZ_TEST_4.csv To: Daily_ABC_TEST_1.csv Daily_ABC_TEST_2.csv Daily_ABC_TEST_3.csv Daily_ABC_TEST_4.csv I have tried the rename command but it is not working (5 Replies)
Discussion started by: alfredo123
5 Replies

5. UNIX for Advanced & Expert Users

Moving multiple files based on the pattern

I want to search for a particular file name patterns and move them to a specific folder, is it possible to do it with awk or sed? (1 Reply)
Discussion started by: rudoraj
1 Replies

6. Shell Programming and Scripting

grouping based on first column

I do have a tab delimited file of the following format a_1 rt a_1 st_2 a_1 st_3 a_2 bt_2 a_2 st_er b_2 st_2 b_2 st_32 S_1 rt_8 S_1 rt_64 I want to cut short the above file and group the file based on the first column like below. a_1 rt st_2 st_3 a_2 bt_2 st_er b_2 st_2... (1 Reply)
Discussion started by: Lucky Ali
1 Replies

7. Shell Programming and Scripting

split XML file into multiple files based on pattern

Hello, I am using awk to split a file into multiple files using command: nawk '{ if ( $1 == "<process" ) { n=split($2, arr, "\""); file=arr } print > file }' processes.xml <process name="Process1.process"> ... (3 Replies)
Discussion started by: chiru_h
3 Replies

8. UNIX for Dummies Questions & Answers

print multiple lines from text file based on pattern list

I have a text file with a list of items/patterns: ConsensusfromCGX_alldays_trimmedcollapsedfilteredreadscontiglist(229095contigs)contig12238 ConsensusfromCGX_alldays_trimmedcollapsedfilteredreadscontiglist(229095contigs)contig34624... (1 Reply)
Discussion started by: Oyster
1 Replies

9. Shell Programming and Scripting

Splitting large file into multiple files in unix based on pattern

I need to write a shell script for below scenario My input file has data in format: qwerty0101TWE 12345 01022005 01022005 datainala alanfernanded 26 qwerty0101mXZ 12349 01022005 06022008 datainalb johngalilo 28 qwerty0101TWE 12342 01022005 07022009 datainalc hitalbert 43 qwerty0101CFG 12345... (19 Replies)
Discussion started by: jimmy12
19 Replies

10. Shell Programming and Scripting

Split a file into multiple files based on the input pattern

I have a file with lines something like. ...... 123_start ...... ....... 123_end .... ..... 456_start ...... ..... 456_end .... ..... 789_start .... .... 789_end (6 Replies)
Discussion started by: abinash
6 Replies
Login or Register to Ask a Question