in reply to Re: Removing the first record in a file containing fixed records
in thread Removing the first record in a file containing fixed records

If ordering is not important he could just read the very last record, overwrite the first record with it and truncate the file before the last record.
  • Comment on Re^2: Removing the first record in a file containing fixed records

Replies are listed 'Best First'.
Re^3: Removing the first record in a file containing fixed records
by Perlbotics (Archbishop) on Jul 18, 2008 at 09:08 UTC
    Since sparkle asked for an efficient method that works even on large files (2GB is sometimes the next limit), I agree with Crackers2 suggestion that will work well since it preserves disk space and implies a minimal amount of copy operations. But in case the header has a different size than the other records, order is important, or in case a copy of the file is still required, I would suggest to give that task away to a tool that is optimised for that kind of operations. Where available, a system(...)-call to tail or dd might be worth consideration.