I need the following grep command to find how many requests per hour are received in logs:
grep 'login log' filelog.txt | grep -c '2017-08-30 ":00 to :23"'
Here the hour 00 till 23, I need to pass as a parameter. For instance, for date 30 I need to see each hour what was the count.
Is it possible using a single command? Currently I have to execute one command for each hour manually. For example,
$grep 'login log' filelog.txt | grep -c '2017-08-30 :00'
123
$grep 'login log' filelog.txt | grep -c '2017-08-30 :01'
456
Here are log lines inside the file which I wanted to count hourly based on time (second column):
2017-08-30 20:19:47 INFO com.java.JavaFile:123 - login log abcduser
So, going by what you say rather than what you do:
Your input (augmented for testing):
Desired result? Printing the hour and the count of matches: