News for hackers. Stuff that matters.
Re:Remove first 300M lines from 700 GB file on 1TB disk by crote on Tuesday September 22, 2020 @10:47AM (#24555022)
You can do it without a temporary file if your filesystem supports sparse files.

Figure out the output size, and create a sparse file with that size. You'll be able to use it like a regular file, but blocks will only take up space once you write to them.

Now simply copy from the input to the output file, starting at the end. Truncate the input file whenever the disk fills up.

There are no comments on this comment yet.