I have a log file that contains information such as this:
date
id number
command1
command2
command3
command4
data
data
data
date
id number
command1
command2
command3
command4
data
data
data
...and so on.
I need to find every time command3 was sent for a specific date. So I need to grep on 'this specific date' and 'command3' and send it to a log file. Is there a way to grep or awk down?
Let's say the log file has this. The end of each entry is separated by a blank line and then the other command string is sent is displayed:
03/17/2011
id number
command1
command2
command3
command4
data
data
data
<blank line>
03/18/2011
id number
command1
command2
command3
command4
data
data
data
<blank line>
03/18/2011
id number
command1
command2
command3
command4
data
data
data
I want some code to do something like:
Read history.log
date=03/18/2011
commandissued=command4
where $date and $commandissues occurs in the same entry (in between blank lines> execute a count and display the results.
Execute the count of what ?
the number of time the command4 has been found for that date ?
or the total number of entries in all record containing the command 4 for that date ?
# cat tst
03/17/2011
id number
command1
command2
command3
command4
data
data
data
03/18/2011
id number
command1
command2
command3
command4
data
data
data
03/18/2011
id number
command1
command2
command3
command4
data
data
data