i have a doubt with the awk script??


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users i have a doubt with the awk script??
# 1  
Old 07-01-2008
Data i have a doubt with the awk script??

Hi Guys,

I am new to this forum, i have doubt with a awk script. I want to generate a list where i can busiest hour from a list of a data.

05/19/2008 14:27:19 - avg: 0 max: 0 min: 0 samples: 0 total: 0
05/19/2008 14:28:19 - avg: 0 max: 0 min: 0 samples: 0 total: 0
05/19/2008 14:29:19 - avg: 0 max: 0 min: 0 samples: 0 total: 0
05/19/2008 14:30:19 - avg: 0 max: 0 min: 0 samples: 0 total: 0
05/19/2008 14:31:19 - avg: 0 max: 0 min: 0 samples: 0 total: 0
05/19/2008 14:32:19 - avg: 0 max: 0 min: 0 samples: 0 total: 0
06/16/2008 17:10:17 - avg: 1 max: 1 min: 0 samples: 1 total: 1
06/16/2008 17:11:17 - avg: 1 max: 1 min: 0 samples: 1 total: 1
06/16/2008 17:12:17 - avg: 1 max: 1 min: 0 samples: 1 total: 1
06/16/2008 17:13:17 - avg: 1 max: 1 min: 0 samples: 1 total: 1
06/16/2008 17:14:17 - avg: 1 max: 1 min: 0 samples: 1 total: 1
06/16/2008 17:15:17 - avg: 1 max: 1 min: 0 samples: 1 total: 1
06/16/2008 17:16:17 - avg: 1 max: 1 min: 0 samples: 1 total: 1
06/16/2008 17:17:17 - avg: 1 max: 1 min: 0 samples: 1 total: 1
06/16/2008 17:18:17 - avg: 1 max: 1 min: 0 samples: 1 total: 1
06/17/2008 14:18:29 - avg: 1 max: 1 min: 0 samples: 1 total: 1
06/17/2008 14:19:29 - avg: 1 max: 1 min: 0 samples: 1 total: 1
06/17/2008 14:20:29 - avg: 1 max: 1 min: 0 samples: 1 total: 1
06/17/2008 14:21:29 - avg: 1 max: 1 min: 0 samples: 1 total: 1
06/17/2008 14:22:29 - avg: 1 max: 1 min: 0 samples: 1 total: 1
06/17/2008 14:23:29 - avg: 1 max: 1 min: 0 samples: 1 total: 1
06/17/2008 14:24:30 - avg: 1 max: 1 min: 0 samples: 1 total: 1
06/17/2008 14:25:30 - avg: 1 max: 1 min: 0 samples: 1 total: 1
06/17/2008 15:46:30 - avg: 1 max: 1 min: 0 samples: 1 total: 1
06/17/2008 15:47:30 - avg: 1 max: 1 min: 0 samples: 1 total: 1
06/17/2008 15:48:30 - avg: 1 max: 1 min: 0 samples: 1 total: 1
06/17/2008 15:49:30 - avg: 1 max: 1 min: 0 samples: 1 total: 1
06/17/2008 15:50:30 - avg: 1 max: 1 min: 0 samples: 1 total: 1
06/17/2008 15:51:30 - avg: 1 max: 1 min: 0 samples: 1 total: 1
06/17/2008 15:52:30 - avg: 1 max: 1 min: 0 samples: 1 total: 1
06/17/2008 15:53:30 - avg: 1 max: 1 min: 0 samples: 1 total: 1
06/17/2008 15:54:30 - avg: 1 max: 1 min: 0 samples: 1 total: 1
06/17/2008 15:55:30 - avg: 1 max: 1 min: 0 samples: 1 total: 1
06/17/2008 15:56:30 - avg: 1 max: 1 min: 0 samples: 1 total: 1
06/17/2008 15:57:30 - avg: 1 max: 1 min: 0 samples: 1 total: 1
06/17/2008 15:58:30 - avg: 1 max: 1 min: 0 samples: 1 total: 1
06/17/2008 15:59:30 - avg: 1 max: 1 min: 1 samples: 3 total: 3

Here in this the second column is the time stamp. I want to find the busiest hour for a particular day.
can u help me guys with this, i tried this but i am not able to get it perfect. i am able to get the result but no perfect.

awk -F':' '{var = $1; if (var ~ /14/) print NR , $0 }' trap.stats | more

the output i get is

1 05/19/2008 14:27:19 - avg: 0 max: 0 min: 0 samples: 0 total: 0
2 05/19/2008 14:28:19 - avg: 0 max: 0 min: 0 samples: 0 total: 0
3 05/19/2008 14:29:19 - avg: 0 max: 0 min: 0 samples: 0 total: 0
4 05/19/2008 14:30:19 - avg: 0 max: 0 min: 0 samples: 0 total: 0
5 05/19/2008 14:31:19 - avg: 0 max: 0 min: 0 samples: 0 total: 0
6 05/19/2008 14:32:19 - avg: 0 max: 0 min: 0 samples: 0 total: 0
7 05/19/2008 14:33:19 - avg: 0 max: 0 min: 0 samples: 0 total: 0
8 05/19/2008 14:35:23 - avg: 0 max: 0 min: 0 samples: 0 total: 0
9 05/19/2008 14:36:23 - avg: 0 max: 0 min: 0 samples: 0 total: 0
10 05/19/2008 14:37:23 - avg: 0 max: 0 min: 0 samples: 0 total: 0
11 05/19/2008 14:38:23 - avg: 0 max: 0 min: 0 samples: 0 total: 0
12 05/19/2008 14:39:23 - avg: 0 max: 0 min: 0 samples: 0 total: 0
13 05/19/2008 14:40:23 - avg: 0 max: 0 min: 0 samples: 0 total: 0
14 05/19/2008 14:41:23 - avg: 0 max: 0 min: 0 samples: 0 total: 0
15 05/19/2008 14:42:23 - avg: 0 max: 0 min: 0 samples: 0 total: 0
16 05/19/2008 14:43:23 - avg: 0 max: 0 min: 0 samples: 0 total: 0
17 05/19/2008 14:44:23 - avg: 0 max: 0 min: 0 samples: 0 total: 0
18 05/19/2008 14:45:23 - avg: 0 max: 0 min: 0 samples: 0 total: 0
19 05/19/2008 14:46:23 - avg: 0 max: 0 min: 0 samples: 0 total: 0
20 05/19/2008 14:47:23 - avg: 0 max: 0 min: 0 samples: 0 total: 0


so i know that on 05/19/2008, during 1400 hrs there were 20 errors.
but i want a more customized trap where i get these errors according to the date.


can u help me guys
# 2  
Old 07-01-2008
Would something like this help?

Code:
cut -c -13 filename | sort | uniq -c

If you are sure the data is sorted - ignore the sort.
# 3  
Old 07-01-2008
Quote:
Originally Posted by asirohi
but i want a more customized trap where i get these errors according to the date.
Show how the customized trap output should look like.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Doubt in awk

Hi, I got a below requirement from this forum, but the solution provided was not clear. Below is the requirement Input file A 1 Z A 1 ZZ B 2 Y B 2 AA Required output B Y|AA A Z|ZZ (5 Replies)
Discussion started by: stew
5 Replies

2. Shell Programming and Scripting

Doubt on using AWK

DE_CODE|1{AXXANY}1APP_NAME|2{TELCO}2LOC|NY DE_CODE|1{AXXATX}1APP_NAME|2{TELCO}2LOC|TX DE_CODE|1{AXXABT}1APP_NAME|2{TELCO}2LOC|BT DE_CODE|1{AXXANJ}1APP_NAME|2{TELCO}2LOC|NJ i have out put file like below i have to convert it in the format as below. DE_CODE = AXXANY APP_NAME= TELCO LOC = NY... (4 Replies)
Discussion started by: mail2sant
4 Replies

3. Shell Programming and Scripting

awk script doubt in extracting and comparing uid

Hi, I need to get the value of 'uid' from a line in file f1. For example, in the line below, I need to get the value '150', from the 'anonuid=150' key, and I need to verify that this is a valid uid by checking it against /etc/passwd (i.e) I want to compare this uid, 150 (or more if there are any... (2 Replies)
Discussion started by: royalibrahim
2 Replies

4. Shell Programming and Scripting

Awk doubt

I have a file sample.txt with the following contents: the following gives output as awk 'NF{s=$0; print s}' sample.txt but, awk 'NF{s=$0}{print s}' sample.txtgives output as why this difference, can someone explain me? (6 Replies)
Discussion started by: royalibrahim
6 Replies

5. Shell Programming and Scripting

doubt on awk

I have executed the below command: find . -name "Ks*" -type f -exec ls -ltr {} \; | awk '{printf("%ld %s %d %s \n",$5,$6,$7,$8,$9)}' and here is the output: 1282 Oct 7 2004 51590 Jul 10 2006 921 Oct 7 2004 1389 Jun 4 2003 1037 May 19 2004 334 Mar 24 2004 672 Jul 8 2003 977... (6 Replies)
Discussion started by: venkatesht
6 Replies

6. Shell Programming and Scripting

Doubt in awk

Hi All, I have two files as given below: fileA 1234|aaaaa|vvvv 2222|bbbbbb|cbxxbjh 3333|cccc|jhjhj fileB 3434|bbbcc|cbxxbjh 1234|cat|bullet 3333|cccc|jhjhj I need a script that reads the first column from fileA (i.e 1234) and searches in fileB in the first parameter(i.e first... (7 Replies)
Discussion started by: jisha
7 Replies

7. Shell Programming and Scripting

doubt in awk

Hi , I have a file in the below format: 1.txt awk 'BEGIN { printf ("%1s", "man" )} ' awk 'BEGIN { printf ("%9s", "women" )} ' awk 'BEGIN { printf ("%56s", "human")} ' ## ### ## echo "$!" ## awk 'BEGIN { printf ("%1s", "aaa" )} ' awk 'BEGIN { printf ("%19s", "bbb" )} ' ... (4 Replies)
Discussion started by: jisha
4 Replies

8. UNIX for Dummies Questions & Answers

doubt about awk

i have a file like this: awk.lst smith : sales : 1200 : 2 jones:it:25000 : 2 roger : it : 1500 : 2 ravi | acct | 15000 i have 3 doubts 1) when i say awk -F ":" '$2 ~ /'it'/ {print $0}' awk.lst i am not able to get jones in the ouput , is it because of space issue? 2)how to... (2 Replies)
Discussion started by: soujanya_srk
2 Replies

9. Shell Programming and Scripting

doubt in AWK

Hi all, column1 -------- 33 44 55 66 please provide the script using awk command to dispaly output 55. Help apperciated.. thanks, Nirmal (4 Replies)
Discussion started by: abnirmal
4 Replies

10. UNIX for Dummies Questions & Answers

awk doubt

I'm having a file with 5 fields. I want to sort that file according to one field no 3. How shall I do using awk programming. Any input appreciatable. regards, vadivel. (7 Replies)
Discussion started by: vadivel
7 Replies
Login or Register to Ask a Question