Need record count on every 30 minute


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Need record count on every 30 minute
# 1  
Need record count on every 30 minute

We have the below records where we need record count of every 30 minute like 00:01 to 00:30 so in that we will have 48 record count in 24 hrs , and also we need sum of record count from 00:01 to 23:30. Please find sample data as well.

Code:
00:01   21
00:02   23
00:03   34
00:04   34
00:05   30
00:06   16
00:07   26
00:08   13
00:09   17
00:10   13
00:11   21
00:12   24
00:13   28
00:14   26
00:15   21
00:16   39
00:17   42
00:18   37
00:19   29
00:20   20
00:21   25
00:22   30
00:23   10
00:24   19
00:25   19
00:26   20
00:27   24
00:28   16
00:29   18
00:30   16
00:31   17
00:32   34
00:33   14
00:34   20
00:35   21
00:36   37
00:37   21
00:38   27
00:39   28
00:40   13
00:41   18
00:42   22
00:43   14
00:44   12
00:45   16
00:46   30
00:47   19
00:48   23
00:49   22
00:50   25
00:51   30
00:52   32
00:53   25
00:54   15
00:55   13
00:56   11
00:57   22
00:58   19
00:59   19
01:00   18
01:01   30
01:02   25
01:03   25
01:04   20
01:05   14
01:06   23
01:07   9
01:08   9
01:09   10
01:10   10
01:11   18
01:12   12
01:13   17
01:14   15
01:15   14
01:16   20
01:17   6
01:18   8
01:19   10
01:20   14
01:21   13
01:22   10
01:23   7
01:24   20
01:25   16
01:26   17
01:27   14
01:28   18
01:29   19
01:30   15
01:31   19
01:32   18
01:33   13
01:34   14
01:35   13
01:36   17
01:37   5
01:38   15
01:39   19
01:40   34
01:41   18
01:42   10
01:43   13
01:44   11
01:45   16
01:46   13
01:47   4
01:48   4
01:49   14
01:50   14
01:51   7
01:52   20
01:53   18
01:54   17
01:55   20
01:56   30
01:57   14
01:58   27
01:59   17
02:00   24
02:01   60
02:02   23
02:03   8
02:04   31
02:05   47
02:06   34
02:07   30
02:08   26
02:09   18
02:10   35
02:11   29
02:12   33
02:13   23
02:14   7

# 2  
For starters, try something like:
Code:
awk '{t+=$2} /:[03]0/{print $1,t; t=0}' file

This User Gave Thanks to Scrutinizer For This Post:
# 3  
Please let me know also how to sum of record count from 00:01 to 23:30.
# 4  
Hello nadeemrafikhan,

Could you please try following and let me know if this helps, though not completely sure about your requirement.
Code:
awk '{split($1, A,":");if(A[2]==30 || A[2]==59){B=B+$NF;print $1 OFS B;B=""};B=B+$NF} END{if(A[2]=30 && A[2]!=59){print $1 OFS B}}'  Input_file

Output will be as follows.
Code:
00:30 711
00:59 635
01:30 495
01:59 469
02:14 445

Thanks,
R. Singh
# 5  
Thanks guys I got the answer of first post but Please let me know also how to sum of record count from 00:01 to 23:30.
# 6  
Hello nadeemrafikhan,

Could you please try following and let me know if this helps you. Also please do mention all requirements in case this doesn't match your requirement with sample Input_file and sample Output too.
Code:
awk '{split($1, A,":");if(A[1]==23 && A[2]==30){print SUM};SUM+=$NF}'  Input_file

Thanks,
R. Singh
# 7  
Your specification is not too clear, as has been stated before, Try
Code:
awk '{SUM += $2; TOT += $2} !(NR%30) {print $1, SUM; SUM = 0} END {print "Total", TOT}' file
00:30 711
01:00 637
01:30 458
02:00 478
Total 2688

 

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #86
Difficulty: Easy
Windows NT was developed as a Unix-like operating system.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Validating the record count

Hi , I am having a text file with several records., it has a header record and trailer record. The header record has the number of rows (records) found in the text file and time-stamp. The footer record has the total number of records ( along with the header and trailer., Suppose: wc -l... (4 Replies)
Discussion started by: cratercrabs
4 Replies

2. Shell Programming and Scripting

Take minute per minute from a log awk

Hi, I've been trying to develop a script that performs the parsing of a log every 1 minute and then generating some statistics. I'm fairly new to programming and this is why I come to ask if I can lend a hand. this is my log: xxxx 16/04/2012 17:00:52 - xxxx714 - E234 - Time= 119 ms.... (8 Replies)
Discussion started by: jockx
8 Replies

3. Shell Programming and Scripting

Count of matched pattern occurences by minute and date in a log file

Anyone knows how to use AWK to achieve the following Sun Feb 12 00:41:01-00:41:59 Success:2 Fail:2 Sun Feb 12 00:42:01-00:42:59 Success:1 Fail:2 Sun Feb 12 01:20:01-01:20:59 Success:1 Fail:2 Mon Feb 13 22:41:01-22:41:59 Success:1 Fail:1 log file: Success Success Fail Fail ... (9 Replies)
Discussion started by: timmywong
9 Replies

4. UNIX for Dummies Questions & Answers

Reduce the count on the 98 record by 2,

recod,amount,noofaccount,count 98,+00000187865779787,00319,000000640/ 99,+00000187865779787,00001,000000642/ thsi is my input file my question is 1) Reduce the count on the 98 record by 2 (6 Replies)
Discussion started by: sgoud
6 Replies

5. Shell Programming and Scripting

Character count per record

I have a flat file. How can i retrive the character count per record in whole file. Can anybody assist me on this Cheers (9 Replies)
Discussion started by: subrat
9 Replies

6. Shell Programming and Scripting

Validate record count

Hi all How to verify the number of records in case of delimited file, If the file has records. And then if it is not equal to mentioned no. of records, email is triggered and file is moved to bad directory path. Example ----- input file = a.txt bad directory path : /usr/bin/bad (6 Replies)
Discussion started by: balaji23_d
6 Replies

7. Shell Programming and Scripting

replaying a record count with another record count

i use unix command to take the record count for a file1 awk 'END{print NR}' filename i already have a file2 which conatin the count like ... .. rec_cnt=100 .. .. I want to replace the record in the file2 using the record i take from file1. suggest me some simple ways of doing it... (2 Replies)
Discussion started by: er_zeeshan05
2 Replies

8. Shell Programming and Scripting

record count

i have a file named file_names.dat where there are several files along with their path. exp: /data1/dir1/CTA_ACD_20071208.dat /data1/dir1/CTA_DFG_20071208.dat i want to write a script which will create a csv file with the name of the file and record count of that file the output file... (4 Replies)
Discussion started by: dr46014
4 Replies

9. Shell Programming and Scripting

Need help with Isql record count

What I am trying to do is check if the database query returned any records. If no records returned then output a message else output results to a file. Right now if I take out the if and else statements the code runs fine and sends the email. If no records returned the email sends the column... (4 Replies)
Discussion started by: johnu122
4 Replies

10. UNIX for Dummies Questions & Answers

How to count the record count in an EBCDIC file.

How do I get the record count in an EBCDIC file on a Linux Box. :confused: (1 Reply)
Discussion started by: oracle8
1 Replies

Featured Tech Videos