bash - awk a huge logfile from behind until timestamp -


i want last part since given timestamp "t0" possible huge logfile (>50..1000mb):

     __________________     |1 xxx xxx ...     |     |2 xxx ...         |     uninteresting part     |4 ...             |     |...               |  ___|423 ...           | ___ timestamp t0     |425 xxx ...       |     |437 ...           |     |...               |     <-- want part ( t0 eof)     |__________________| 

and additional constraint want using simple bash commands. simple solution may be:

awk '$1 > 423' file.log 

but scans whole file unintresting lines. there's command tail can give him number of last lines want don't know - know timestamp. there way "awking" behind , stop processing when first timestamp doesn't match?

tac friend here:

tac file.log | awk '{ if ($1 >= 423) print; else exit; }' | tac 

tac dump each line of file starting last line, working beginning of file. once lines want, again fix order.


Comments