1754402 Members
3548 Online
108813 Solutions
New Discussion юеВ

manipulating vi editor

 
SOLVED
Go to solution
mw_4
Frequent Advisor

manipulating vi editor

Hi.
can someone notify me that too big files are editted in vi command..
ie, opening 2GB file first
and insert, delete, ... and so on..
How can I do that? or
the way to go what i want to edit first not open the entire file but open part of file and manipulate
Step by step
4 REPLIES 4
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: manipulating vi editor

You would be wiser to use a scripting language like Perl. If you must use vi then you should use the split command to break the file into more manageable pieces.

split -l 50000 file will split file into fileaa, file ab, fileac, ... each 50,000 lines long. You can edit these and these recombine them using cat file* > newfile.

Man split for details.
If it ain't broke, I can fix that.
Sanjay_6
Honored Contributor

Re: manipulating vi editor

Hi,

If this is a long file, you can use split to split the file into parts, edit them and then join them together.

Hope this helps.

Regds
steven Burgess_2
Honored Contributor

Re: manipulating vi editor

Hi

Here is a thread regarding editing large files that vi cannot handle

http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x5c1deea29889d611abdb0090277a778c,00.html

Regards

Steve
take your time and think things through
Bill Hassell
Honored Contributor

Re: manipulating vi editor

Using vi will never work. At the bottom of the man page is the list of limitations, specifically, 234,000 lines max. But even if your file is only 200,000 lines, vi needs several temp areas which have to be at least as large as the original file, or double the size of the original file.

You have to use sed or awk depensding on what you need to change. An interactive editor w]won't work.


Bill Hassell, sysadmin