Print out the amount of times 2 words appear in the syslog. But also have it tell me how many times for each hour

Posted by wolfspinone on Ask Ubuntu See other posts from Ask Ubuntu or by wolfspinone
Published on 2014-06-04T17:36:03Z Indexed on 2014/06/04 21:42 UTC
Read the original article Hit count: 159

Filed under:
|

So I'm trying to create a bash script that looks for two words in my syslog file. Then I want the script to print out how many times those two words have appeared. Also I want it to print it out for every hour of the day. So like if the word dog appeared 4 times during the first hour of today, it says Hour one, dog 4. Finally at the end of the script I want it to print out how many times those words appeared all day.

The sudo code I have thus far is

if 2 > hour
find permit
find block
print both
finish

if 1 < hour < 2
find permit
find block
print both
finish

if 2 < hour < 3
find permit
find block
print both
finish

command is grep -o "\WORD\" Syslog.txt * | sort | uniq -c

© Ask Ubuntu or respective owner

Related posts about bash

Related posts about scripting