[Linux-disciples] Deleting the first N lines of a file
Adam Rosi-Kessel
adam at rosi-kessel.org
Thu Feb 9 11:36:20 EST 2006
Stephen R Laniel wrote:
> On Wed, Feb 08, 2006 at 08:55:49PM -0500, Stephen R Laniel wrote:
>> Does anyone know of a very fast way to delete the first N
>> lines of a file? (That is, after the deletion, the file's
>> size will reduce from N + k to k lines.) Speed is rather
>> important here, so something like
>
> I was thinking that maybe
>
> NUMLINES=`some command involving grep`
> head -n $NUMLINES filename > outfile.txt
> sed -i "1,${NUMLINES}d" filename
>
> would do the trick. But I'm playing with that now, on a
> fairly representative very large file, and it seems to take
> a very long time. Hm.
It doesn't matter if it takes a long time, so long as it doesn't lose hits,
right?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 250 bytes
Desc: OpenPGP digital signature
Url : http://lists.bostoncoop.net/pipermail/linux-disciples/attachments/20060209/29c83fc4/signature.pgp
More information about the Linux-disciples
mailing list