Chopping then Catting
You could always use split
with any of its various options to make smaller files, then edit the last file, and concatenate them back together with cat
when you're done.
Or use csplit
, to chop off only the end piece.
A Better Way
As Charles Duffy points out, it would be more efficient to use dd
to seek near the end of the file, read the contents and edit them, then use dd
again to tack it back on.
This is especially important when dealing with really huge files.
Changing the editor
With Vim you can also do set noswapfile
, set nobackup
and syntax off
to reduce the load of the editor on your system.
Or you could try vim -u "NONE" file.csv
to use Vim without any plugins.
Note: The first two methods assume that you don't know exactly (i.e. line number or pattern) where you want to edit yet.
]
– user3635159 Oct 07 '14 at 13:27" >>file`
– Charles Duffy Oct 08 '14 at 03:57with ?
– user3635159 Oct 08 '14 at 07:15@@"`. That said, that'll change it everywhere in the document; if you know the line number for the single line where it needs changing, though, that can be passed to `sed` too. To only edit the area between the 15,000th line and the end of file, for instance: `sed -i '15000,$s@@@'`. If you have a `sed` without GNU extensions, the *standard* (and actually better) tool for this kind of in-place edit is `ex`.
– Charles Duffy Oct 08 '14 at 13:22