[SATLUG] using grep
Brad Knowles
brad at shub-internet.org
Thu Sep 20 23:51:12 CDT 2007
On 9/20/07, twistedpickles wrote:
> what I have tried and hasn't worked is:
> $grep -c 15:[0-59]:[0-59] tmpIEEE-17.txt
> above displays 0
> $grep -c [15:00:00-15:59:59] tmpIEEE-17.txt
> above counts every line in the log
Your shell is almost certainly interpreting the brackets for you.
Try putting your arguments to grep into single quotes.
For my part, if this is the format in the log file:
[2007-09-20 15:13:23] User IEEE permitted in class Public
I'd be inclined to do something like this:
$ awk '{ print $2 }' < tmpIEEE-17.txt | sed 's/:.*$//g' | uniq -c
What this does is use the program "awk" to pull out the second
whitespace-delimited argument from each line (the stuff like
"15:13:23]"), then use "sed" to strip off everything after the first
colon. This should give you a long list of hours. Then pipe that to
"uniq -c" to get a count of how many times each hour shows up in the
output.
--
Brad Knowles <brad at shub-internet.org>
LinkedIn Profile: <http://tinyurl.com/y8kpxu>
More information about the SATLUG
mailing list