Wow. 200MB?? That's a huge text file. Personally, I would first rotate that log to a more manageable size first.
... you could use the tail command with the + operand..
...so you'd do something like this ( not complete code, but you'll get the idea):
Code:
# cat logfile | wc -l >> marker.txt ## where marker has the number of lines in
## your logilfe at the end of your script
... then. next time you run your script:
Code:
# COUNT=$(cat marker)
let MARKER=${COUNT}+1
# tail +$(MARKER} logfile
...and you'll only get the lines in the logfile that were appended after the last time you checked.
I'd still strongly suggest you rotate that log file more often first. It's easier and faster to work with closed, smaller sized files.
... quick example of the difference between tail -n and tail +n :
..say you have a file:
Code:
# cat file
111111111111
2222222222222
33333333333333
44444444444444
555555555555555
666666666666666
777777777777777
88888888888888
999999999999999
aaaaaaaaaaaaa
bbbbbbbbbbbbb
ccccccccccccc
#tail -5 file
88888888888888
999999999999999
aaaaaaaaaaaaa
bbbbbbbbbbbbb
ccccccccccccc
# tail +5 file
555555555555555
666666666666666
777777777777777
88888888888888
999999999999999
aaaaaaaaaaaaa
bbbbbbbbbbbbb
ccccccccccccc
Last edited by System Shock; 05-23-2006 at 08:25 PM..
|