from the above logfile i need to get the lines between the two timestamps,if i give
2013-08-02 (start) & 2013-08-05 (end)
i am getting the content.
But wen i give
2013-08-01 (start) and 2013-08-05 (end)
i didnt get the output.
my reqiurement is even though 2013-08-01 is not there wen i give 2013-08-01 as start date it should calculate and give the lines.
Please help me guys.
I think this can be done through some date manipulation.
st="2013-08-01"
en="2013-08-03"
awk -v ST="$st" -v EN="$en" '
{
V = $1
gsub ( "-", X, V )
gsub ( "-", X, ST )
gsub ( "-", X, EN )
if ( V >= ST && V <= EN )
print
}
' file.log
Hi guys thanks for your reply,
when i run the above script i didnt get any output.
[ 2013-08-02 04:01:23 pid=15642 ppid=15642 ] Exited the Programme
[ 2013-08-02 03:59:14 pid=15690 ] Exited the Programme, recovery completed
[ 2013-08-03 09:15:37 pid=21374 ] Exited the Programme, recovery completed
[ 2013-08-03 09:19:49 pid=21773 ] Exited the Programme, recovery
[ 2013-08-04 09:26:44 pid=22199 ] Exited the Programme, recovery completed
the code i run is
#!/bin/ksh
st="2013-08-01"
en="2013-08-03"
awk -v ST="$st" -v EN="$en" '
{
V = $1
gsub ( "-", X, V )
gsub ( "-", X, ST )
gsub ( "-", X, EN )
if ( V >= ST && V <= EN )
print
}
' recovery.log