News for hackers. Stuff that matters.
Re:Why GNU grep is Fast by astine on Monday August 23, 2010 @09:36AM (#1626713)
Or rather, compared to a server log file that hasn't been properly rotated. I wrote a program a while back to incrementally parse a daily log file which was never rotated. It got say that it would take twenty minutes for for the program to just skip the lines that had been parsed previously. When those who had the power to do so started rotating the file, things speed up tremendously.
Re:Why GNU grep is Fast by jonknee on Monday August 23, 2010 @10:19AM (#1626812)
Why didn't you split it?
Re:Why GNU grep is Fast by fr0sty on Monday August 23, 2010 @11:00AM (#1626933)
Sparing that, why not use fseek() and do a binary search to get to where you wanted to go? Even better, save the prior offset somewhere and jump there immediately on T+1?
Re:Why GNU grep is Fast by astine on Monday August 23, 2010 @02:37PM (#1627581)
That, I should have done. I thought to save the number of lines previously read so that I could skip them; I don't know why it didn't occur to me to just save the whole damn offset.
Re:Why GNU grep is Fast by sigil on Monday August 23, 2010 @12:58PM (#1627263)
I used this trick the other day -- compute byte range partitions on a large file and use fseek when processing each. Is there a standard unix program that can output an arbitrary byte range from a seekable input? At first blush dd(1) looked like the ticket, but block-oriented operation means extra invocations to deal with a byte range that's not necessarily block-aligned.
Re:Why GNU grep is Fast by jacquesm on Monday August 23, 2010 @02:32PM (#1627557)
tail -c offset [input] | head -c length

will do the job.

Re:Why GNU grep is Fast by pmjordan on Tuesday August 24, 2010 @05:08AM (#1629341)
You can set dd's "bs" parameter to 1, then seek, skip & count are all in terms of bytes.
Re:Why GNU grep is Fast by astine on Monday August 23, 2010 @02:20PM (#1627524)
I couldn't, I didn't have control over the file.