bash - select log messages between two dates -


i want extract log messages between 2 dates. problem date format below.

[tthangavel@localhost test]$ cat file may 1 06:00:08 localhost my_process: myfield,bras_vci,1,1,10000000,10000000000,e,rtt,125,50,200,5,601,17635626,50,15841153,4928488,14274344,0,-,17560 may 12 06:00:08 localhost my_process: myfield,bras_vci,1,1,10000000,10000000000,e,rtt,125,50,200,5,601,17635626,50,15841153,4928488,14274344,0,-,17560 may 13 06:00:07 localhost my_process: myfield,bras_vci,1,1,10000000,10000000000,-,rtt,55,50,200,5,813,10000000000,96,22859361,5306968,19470856,0,-,17559 may 14 06:00:07 localhost my_process: myfield,bras_vci,1,1,10000000,10000000000,-,rtt,56,50,200,5,762,10000000000,96,17805577,4979448,13233936,0,-,17559 may 15 06:00:07 localhost my_process: myfield,bras_vci,1,1,10000000,10000000000,-,rtt,56,50,200,5,848,10000000000,96,19767812,5691888,14387304,0,-,17559 jun 10 06:00:08 localhost my_process: myfield,bras_vci,1,1,10000000,10000000000,e,rtt,125,50,200,5,601,17635626,50,15841153,4928488,14274344,0,-,17560 jun 11 06:00:07 localhost my_process: myfield,bras_vci,1,1,10000000,10000000000,-,rtt,55,50,200,5,813,10000000000,96,22859361,5306968,19470856,0,-,17559 jun 15 06:00:07 localhost my_process: myfield,bras_vci,1,1,10000000,10000000000,-,rtt,56,50,200,5,762,10000000000,96,17805577,4979448,13233936,0,-,17559 jul 10 06:00:07 localhost my_process: myfield,bras_vci,1,1,10000000,10000000000,-,rtt,55,50,200,5,813,10000000000,96,22859361,5306968,19470856,0,-,17559 jul 14 06:00:07 localhost my_process: myfield,bras_vci,1,1,10000000,10000000000,-,rtt,56,50,200,5,848,10000000000,96,19767812,5691888,14387304,0,-,17559 jul 15 06:00:06 localhost my_process: myfield,bras_vci,1,1,10000000,10000000000,-,rtt,56,50,200,5,968,10000000000,96,20602499,4746960,20327184,0,-,17559 

i tried below, got error.

[tthangavel@localhost test]$ cat file | awk -vbegin=$(date -d"jun 14 05:39:00" +%s) 'system("date -d\"$1 $2 $3\" +%s") > begin {print $0}' 1468900800 1468900800 1468900800 1468900800 1468900800 1468900800 1468900800 1468900800 1468900800 1468900800 1468900800 1468900800 

if lines in log file ordered date (as seems likely), sed job nicely

$ begin='may 12'; end='jun 15' $ sed -ne "/^$begin/,/^$end/p" input 

Comments

Popular posts from this blog

gridview - Yii2 DataPorivider $totalSum for a column -

java - Suppress Jboss version details from HTTP error response -

Sass watch command compiles .scss files before full sftp upload -