views:

787

answers:

6

Hello,

I have a huge (~2GB) file that I need to navigate around. I don't actually need to edit it, just jump around efficiently.

I tried vim but it choked.

Any recommendations for working with huge files on Linux?

Thanks

A: 

Here is a similar question.

GeoAvila
yeah I saw it, but it's targeted at Windows
Plumo
Emacs is for unix/linux OS.
GeoAvila
A: 

emacs works very well with files into the 100's of megabytes, I've used it on log files without too much trouble.

But generally when I have some kind of analysis task, I find writing a perl script a better choice.

Andy Ross
+3  A: 

Since you don't need to actually edit the file:

  1. view (or vim -R) should work reasonably well on large files.
  2. Or you can use more or less
ChssPly76
vim with "-R" still chokes. Less is a good idea.
Plumo
By "chokes" you mean takes a while to open? Or actually crashes? It takes a bit over 4 minutes on my not-so-recent Linux box to open 2.7GB file in `view` (just tried and timed). Granted, that's not exactly instant, but it does work.
ChssPly76
Yeah it stalls. I am sure if I waited it would open eventually. I've gone with less because it opens immediately and I'm used to the navigation.
Plumo
+7  A: 

Vim has a LargeFile plugin for larges files. It will basically configure vim to not use a swap file and undo levels when opening big files (like in Vim Tip 611).

But I think I'd rather use grep and split to navigate in such a file (see Grep with large patterns files).

Pascal Thivent
+1  A: 

This has been a recurring question for many years. (The numbers keep changing, but the concept is the same: how do I view or edit files that are larger than memory?)

Obviously more or less are good approaches to merely reading the files --- less even offers vi like keybindings for scrolling and searching.

A Freshmeat search on "large files" suggests that two editors would be particularly suited to your needs.

One would be: lfhex ... a large file hex editor (which depends on Qt). That one, obviously, entails using a GUI.

Another would seem to be suited to console use: hed ... and it claims to have a vim-like interface (including an ex mode?).

I'm sure I've seen other editors for Linux/UNIX that were able to page through files without loading their entirety into memory. However, I don't recall any of their names. I'm making this response a "wiki" entry to encourage others to add their links to such editors. (Yes, I am familiar with ways to work around the issue using split and cat; but I'm thinking of editors, especially console/curses editors which can dispense with that and save us the time/latencies and disk space overhead that such approaches entail).

Jim Dennis
A: 

I tried to edit a huge file of 7GB with PilotEdit. But it may take you 15 minutes to open/save a 2GB file. After you open the file, you can view/edit it quickly. You may try to open FTP files with PilotEdit.

Dracoder