Edit very large sql dump/text file (on linux) Edit very large sql dump/text file (on linux) linux linux

Edit very large sql dump/text file (on linux)


Rather than removing the first few lines, try editing them to be whitespace.

The hexedit program can do this-- it reads files in chunks, so opening a 10GB file is no different from opening a 100KB file to it.

$ hexedit largefile.sql.dumptab (switch to ASCII side)space (repeat as needed until your header is gone)F2 (save)/Ctrl-X (save and exit)/Ctrl-C (exit without saving)


joe is an editor that works well with large files. I just used it to edit a ~5G SQL dump file. It took about a minute to open the file and a few minutes to save it, with very little use of swap (on a system with 4G RAM).


sed 's/OLD_TEXT/NEW_TEXT/g' < oldfile > newfile

or

cat file | sed 's/OLD_TEXT/NEW_TEXT/g' > newfile