Once I needed to prepend a line (
use this_database;) to a tremendous sql dump. None of my text editors could open it whatsoever.
I found a shell one liner which did this job perfectly. But I forgot a semicolon at the end of the line (oops.. haven’t backed up initial sql file). So I needed to remove that line and add proper one.
As a conclusion of this cool story see two commands below.
Prepend a line to huge file
I could change the output file’s name, just to be on the safe side, but didn’t want another 5GB file on my SSD.
Remove the first line from a huge file: