counting word xx referred to a time period, like minute or hour


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting counting word xx referred to a time period, like minute or hour
# 1  
Old 03-25-2011
counting word xx referred to a time period, like minute or hour

Hello,
I try to insert a post because I've got a trouble to perform a unix job. But I didn't found which steps (procedure) I should follow. Could you help me?

I got a log by my Application box, like following:

Code:
gbosmam037:test >view Log_Server.csv 
    MSG_ID|TRANS_ID|CLIENT_ID|REQUEST_TYPE|SPCLASS|SPSERVICE|ID_TEMPLATE|REQUEST_DATE|ANSWER_DATE
  98891142418714|98891142418714|108114|MT|000|C06 SintaxERR||2011-02-20 00:00:00,003|2011-02-20 00:00:00,033
  98881142418715|98881142418715|108114|MT|000|C06 SintaxERR||2011-02-20 00:00:00,159|2011-02-20 00:00:00,163
  98891142418716|98891142418716|108114|MT|075|Voting||2011-02-20 00:00:00,313|2011-02-20 00:00:00,317
  98881142418717|98881142418717|108114|MT|075|Voting||2011-02-20 00:00:00,439|2011-02-20 00:00:00,442
  98891142418718|98891142418718|108114|MT|075|Voting||2011-02-20 00:00:00,570|2011-02-20 00:00:00,583
  98881142418719|98881142418719|108114|MT|075|Voting||2011-02-20 00:00:00,699|2011-02-20 00:00:00,708
  98891142418720|98891142418720|108114|MT|075|Voting||2011-02-20 00:00:00,781|2011-02-20 00:00:00,785
  98881142418721|98881142418721|108114|MT|075|Voting||2011-02-20 00:00:00,910|2011-02-20 00:00:00,915
  98891142418722|98891142418722|108114|MT|075|Voting||2011-02-20 00:00:01,600|2011-02-20 00:00:01,607
  98881142418723|98881142418723|108114|MT|075|Voting||2011-02-20 00:00:01,732|2011-02-20 00:00:01,737
  98891142418724|98891142418724|108114|MT|075|Voting||2011-02-20 00:00:01,859|2011-02-20 00:00:01,863
  98881142418725|98881142418725|108114|MT|075|Voting||2011-02-20 00:00:01,995|2011-02-20 00:00:02,009
  98891142418726|98891142418726|108114|MT|075|Voting||2011-02-20 00:00:02,139|2011-02-20 00:00:02,145
  98881142418727|98881142418727|108114|MT|075|Voting||2011-02-20 00:00:02,270|2011-02-20 00:00:02,274
  98891142418728|98891142418728|108114|MT|075|Voting||2011-02-20 00:00:02,402|2011-02-20 00:00:02,407
  98881142418729|98881142418729|108114|MT|075|Voting||2011-02-20 00:00:02,529|2011-02-20 00:00:02,533
  98881142418730|98881142418730|108083|MT|000|C06 SintaxERR||2011-02-20 00:00:02,660|2011-02-20 00:00:02,665
  98891142418731|98891142418731|108114|MT|075|Voting||2011-02-20 00:00:02,670|2011-02-20 00:00:02,674
  98881142418732|98881142418732|108114|MT|075|Voting||2011-02-20 00:00:02,831|2011-02-20 00:00:02,835
  98891142418733|98891142418733|108083|MT|000|C06 SintaxERR||2011-02-20 00:00:02,833|2011-02-20 00:00:02,837
  98881142418734|98881142418734|108083|MT|000|C06 SintaxERR||2011-02-20 00:00:02,962|2011-02-20 00:00:02,969
  98891142418735|98891142418735|108114|MT|075|Voting||2011-02-20 00:00:02,965|2011-02-20 00:00:02,970
  ....

I tried to write a unix script to: counting how many time log files contain the same 'word' referred on a time period (time period can be like minute or hour).
The word could be '108114' and the program could permit to insert the time-period search parameter.
Thanks,

Luca
Moderator's Comments:
Mod Comment
Please use code tags when posting data and code samples!

Last edited by vgersh99; 03-25-2011 at 12:23 PM.. Reason: code tags, please!
# 2  
Old 03-25-2011
we'd like to see the following;

a.) more details regarding input parameters
b.) sample output with how those input parameters will work
c.) your script attempt at solving the problem

other than that, i can push in the right direction by either recommending something like:

Code:
awk -F\| '{ if ( $6 ~ input_string ){ print $0; }}' input_string="$*" log_file_nm

or...
Code:
grep "2011-02-20 ..:${MIN}:" log_file_nm

... etc....
# 3  
Old 03-25-2011
Update parameters for counting word referred to a time period

The script is launched with log-file and 2 parameters, like:
Code:
script  ‘Log_Server.csv’ ‘time-period’ ‘key-search’
   where:
* 

time-period : could be minutes (m) or hour (h)

*key-search: could be 108114 or 108083


Sometimes it works and sometime it answer an error.


Code:
gbosmam037:test  >./script.sh Log_Server.csv h  108114
 mch-stat-sm
  Parsing input file.  Please wait...
 
 Log start at 2011-02-20  00:00
 Log stop at   :
   RESULTS FOR CLIENT_ID  =  108114
  Time # MT Numbers #  Speed MT/sec
 ./mch-stat-sm.LMM.sh:  test: argument expected
gbosmam037:test  >


 gbosmam037:test  >./script.sh Log_Server.csv h        
 mch-stat-sm
  Parsing input file.  Please wait...
 
 Log start at 2011-02-20  00:00
 Log stop at 2011-02-20  23:59
   RESULTS FOR ALL  CLIENT_IDs 
  Time # MT Numbers #  Speed MT/sec
 00 # 62381 #  17
 01 # 231 #  0
 02 # 195 #  0
 03 # 73 #  0
 04 # 242 #  0
 05 # 314 #  0
 06 # 362 #  0
 07 # 474 #  0
 08 # 2630 #  0
 09 # 5202 #  1
 10 # 8837 #  2
 11 # 3619 #  1
 12 # 2401 #  0
 13 # 1273 #  0
 14 # 1343 #  0
 15 # 2925 #  0
 16 # 7299 #  2
 17 # 1745 #  0
 18 # 2815 #  0
 19 # 4381 #  1
 20 # 1834 #  0
 21 # 9564 #  2
 22 # 6042 #  1
 23 # 6335 #  1
 gbosmam037:test  >
 

gbosmam037:test  >./script.sh Log_Server.csv h  108083
   mch-stat-sm 

 Parsing input file.  Please  wait...
 
 Log start at 2011-02-20  00:00
 Log stop at 2011-02-20  22:59
    RESULTS FOR CLIENT_ID  =  108083 

 Time # MT Numbers #  Speed MT/sec
 00 # 30997 #  8
 01 # 12 #  0
 02 # 2 #  0
 03 # 0 #  0
 04 # 101 #  0
 05 # 33 #  0
 06 # 98 #  0
 07 # 73 #  0
 08 # 3 #  0
 09 # 4 #  0
 10 # 6 #  0
 11 # 5 #  0
 12 # 3 #  0
 13 # 9 #  0
 14 # 2 #  0
 15 # 2 #  0
 16 # 2 #  0
 17 # 84 #  0
 18 # 384 #  0
 19 # 401 #  0
 20 # 317 #  0
 21 # 1217 #  0
 22 # 2 #  0
 gbosmam037:test  >



Attached you can see my script.
I will appreciate if you can help me.


Luca
Moderator's Comments:
Mod Comment
Please use code tags when posting data and code samples!




Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

[solved] Awk/shell question to parse hour minute from text

Hi, I have a quick question on parsing the hour/minute and value from a text file and remove the seconds portion. For example in the below text file: 20:26:01 95.83 20:27:01 96.06 20:28:01 95.99 20:29:01 7.11 20:30:01 5.16 20:31:01 8.27 20:32:02 9.79 20:33:01 11.27 20:34:01 7.83... (2 Replies)
Discussion started by: satishrao
2 Replies

2. Shell Programming and Scripting

How to convert 24 hour time to 12 hour timing?

Hi friends, I want to convert 24 hour timing to 12 hour please help me... my data file looks like this.. 13-Nov-2011 13:27:36 15.32044 72.68502 13-Nov-2011 12:08:31 15.31291 72.69807 16-Nov-2011 01:16:54 15.30844 72.74028 15-Nov-2011 20:09:25 15.35096 ... (13 Replies)
Discussion started by: nex_asp
13 Replies

3. Shell Programming and Scripting

return counting per hour percentage

We have a monitoring process for a load in unix box, during this process we are writing logs statements for each record, and during this process we are showing the counts per hour. Here is that how we are following log files statements: (just two lines printed here), these statements logged at... (1 Reply)
Discussion started by: skkuchipudi
1 Replies

4. UNIX for Dummies Questions & Answers

How to add an hour or a minute to a time?

Hi, The timestamp is June 06 2011 11:05AM i need 2 results. first, an hour added to it, June 06 2011 12:05AM second, a minute added to it, June 06 2011 11:06AM How can i do this? Also when it reaches 12:59, it needs to start from 1 again without giving the output as 13:00. it... (17 Replies)
Discussion started by: irudayaraj
17 Replies

5. Shell Programming and Scripting

Trim the sentence containing colon and period to extract a word in between

Hello All , i am a newbie in korn shell scripting trying to trim a sentence that is parsed into a variable . The format of the sentence has three words that are separated from other by a " : " colon and "." period . Format of the sentence looks like ... (5 Replies)
Discussion started by: venu
5 Replies

6. Shell Programming and Scripting

Crontab for every minute or every hour

How to set crontab for every minute or every hour (1 Reply)
Discussion started by: kaushik02018
1 Replies

7. Shell Programming and Scripting

Counting average data per hour

Hi i have log like this : Actually i will process the data become Anybody can help me ? (6 Replies)
Discussion started by: justbow
6 Replies

8. Shell Programming and Scripting

Time difference in Minute in UNIX

is there any ways to get the time difference between 2 dates in UNIX? for example, For below date the outut should come 22 minutes startdate enddate ========= ======= 06/17/2008 13:25 06/17/2008 13:47 For, below date, the output should come 1462 minutes ... (5 Replies)
Discussion started by: Amit.Sagpariya
5 Replies

9. Shell Programming and Scripting

record wc -l over 24 hour period

I need to keep track of this output echo "dis chs(*)" | runmqsc | grep RUNNING | wc -l I need to record that count once an hour 24 hours a day and write to a file with the date and time it was run. Any idea on how to do this. (5 Replies)
Discussion started by: csaunders
5 Replies
Login or Register to Ask a Question