[RLUG] quick question
Bruce Robertson
bruce at greatbasin.net
Wed Jun 28 16:42:54 PDT 2006
You could do it in C, and do something like this:
open the file for reading with one file descriptor (RFD below)
open the file for writing with another descriptor (WFD below)
read the file with RFD until you've skipped 300 newlines
start copying from RFD to WFD until you've hit the end of the file.
do a truncate() on WFD.
That should do it, but I'd suggest testing with a copy of the file... :-)
Bruce Robertson, President/CEO +1-775-348-7299
Great Basin Internet Services, Inc. company-wide fax: +1-775-348-9412
http://www.greatbasin.net my efax: +1-775-201-1553
Grant Kelly wrote:
> Alright unix fans, who can answer this the best?
>
> I have a text file, it's about 2.3 GB. I need to delete the first 300
> lines, and I don't want to have to load the entire thing into an
> editor.
>
> I'm trying `sed '1,300d' inputfile > output file` but it's taking a
> long time (and space) to output everything to the new file.
>
> There has got to be a better way, a way that can do this in-place...
>
>
> Grant
>
> _______________________________________________
> RLUG mailing list
> RLUG at rlug.org
> http://lists.rlug.org/mailman/listinfo/rlug
>
>
>
>
>
>
More information about the RLUG
mailing list