Tag Archives: ex

Text Manipulation: How to Delete the First Line of Text in a Large File

Editing a very large file can be a resource- (and time-) consuming nightmare. Having a requirement to delete the first line in such a file in-place whilst avoiding opening the file up in SomeEditor(TM) can be done in various ways, with various resource overheads.

Let me introduce you to the three methods we’ll be trying. The first uses GNU sed and the -i (inplace) option to edit the file in-place.

The second methods uses perl to get the job done.

The final example uses printf (so use a shell that supports it) and ex (command-line vi).

Let’s use these methods and time them…

So the moral of this tip? Use perl for performing edits on extremely large files!