I am requesting help related to the grep command
Hi All,
I would like to know how to use grep command to filter the log files created between 3:00 PM to 4:30 PM in buch of log for whole day in different headings. This files resembles like sar file in linux. Please help with this query. Thanks... |
Please post some lines from the log files
|
Quote:
03:00:01 0 21.21 0.00 33.99 0.00 0.00 44.80 03:00:01 1 1.89 0.00 3.51 0.00 0.00 94.61 03:00:01 2 1.55 0.00 8.79 0.01 0.00 89.66 03:00:01 3 1.61 0.00 2.88 0.00 0.00 95.51 03:00:01 4 1.51 0.00 6.87 0.00 0.00 91.63 03:00:01 5 1.49 0.00 2.88 0.00 0.00 95.62 03:00:01 6 1.17 0.00 6.52 0.00 0.00 92.31 03:00:01 7 1.58 0.00 2.88 0.00 0.00 95.54 03:10:01 all 4.03 0.00 8.50 0.00 0.00 87.47 03:10:01 0 21.86 0.00 34.64 0.00 0.00 43.50 03:10:01 1 1.75 0.00 3.18 0.00 0.00 95.07 03:10:01 2 1.52 0.00 8.58 0.01 0.00 89.89 03:10:01 3 1.58 0.00 2.82 0.00 0.00 95.60 03:10:01 4 1.44 0.00 6.69 0.00 0.00 91.88 03:10:01 5 1.50 0.00 2.73 0.00 0.00 95.77 03:10:01 6 1.17 0.00 6.59 0.00 0.00 92.24 03:10:01 7 1.47 0.00 2.73 0.00 0.00 95.80 03:20:01 all 4.11 0.00 8.42 0.00 0.00 87.47 03:20:01 0 22.75 0.00 35.39 0.00 0.00 41.87 03:20:01 1 1.74 0.00 3.20 0.00 0.00 95.05 03:20:01 2 1.43 0.00 8.34 0.00 0.00 90.23 03:20:01 3 1.46 0.00 2.58 0.00 0.00 95.96 03:20:01 4 1.40 0.00 6.33 0.00 0.00 92.27 I have provided few lines from the log file like this we have many catogaries and each will be logged for the hole day.. |
Thanks for the extra information. sed and awk may be better tools for the job and some regular posters here are very good with those tools so I'll not write more until they have had a chance to respond. At least they will know the format of the files now.
|
Quote:
@srajeshkumar: actually I will suggest a solution in bash, since the date command is more flexible than the time functions in awk. Here we go: Code:
#!/bin/bash Code:
./script.sh "03:00 AM" "03:15 AM" file.log |
And here is a slightly faster solution using both shell and awk:
Code:
#!/bin/bash |
All times are GMT -5. The time now is 12:09 PM. |