Unix command-line editor for big files

4

1

I sometimes run into the problem where I need to replace just a few characters in files ~10Gb. As I only have 2Gb RAM, opening such a file with Vim or nano will consume all system resources.

The way I do it now is I either do my changes with sed, which is not very convenient, or I use a combination of head and tail to split out a smaller part of the file, edit that, then cat back together the pieces. Even less convenient.

So, does anyone know an editor that doesn't load the whole file into memory (or perhaps a switch I can use with vim or another popular editor)?

Attila O.

Posted 2010-12-03T13:09:40.870

Reputation: 1 200

@akira: thanks, I thought SuperUser is for things like this so I forgot to check StackOverflow first. – Attila O. – 2010-12-03T14:03:27.763

1the question is just perfectly fine here (better than on SO, imho), but the link might help others and linking is the way how the web works. – akira – 2010-12-03T14:09:36.673

Answers

2

you can configure vim to behave better with large files:

http://www.vim.org/scripts/script.php?script_id=1506

Editing large files can be a time consuming process as Vim is working on 
a number of things behind the scenes, such as maintaining an undo database, 
searching for a syntax highlighting synchronization point, etc.  

LargeFile.vim is a very small "plugin"; mostly, its just an autocmd that 
disables certain features of vim in the interests of speed. 

akira

Posted 2010-12-03T13:09:40.870

Reputation: 52 754