33

I have got a 4 GiB txt file that I need to view.

When I try to open it in Gedit it loads for a while and then crashes.

Do you have any ideas for a text editor that I can use to view this file? My OS is Fedora 20.

Milan
  • 1,743
  • 2
  • 13
  • 36
user3213163
  • 607
  • 3
  • 8
  • 10
  • 1
    see also: https://stackoverflow.com/questions/159521/text-editor-to-open-big-giant-huge-large-text-files – voy Jan 18 '18 at 14:53
  • Stack Overflow is a site for programming and development questions. This question appears to be off-topic because it is not about programming or development. See [What topics can I ask about here](http://stackoverflow.com/help/on-topic) in the Help Center. Perhaps [Software Recommendations Stack Exchange](http://softwarerecs.stackexchange.com/) would be a better place to ask. – jww Aug 28 '18 at 10:22
  • Use the split command. See https://askubuntu.com/a/28861/108176 for details. – Alan Hamlett Sep 02 '18 at 22:04

6 Answers6

52

BEHOLD! Since glogg looks unmaintained klogg is better alternative nowadays

apt install klogg

Try glogg. It worked great for me.

Debian:

apt-get install glogg

Fedora:

yum install glogg
voy
  • 1,568
  • 2
  • 17
  • 28
29

Not text editors, but in the command line tail -n 100 ./file.txt will give you the last 100 lines of a file, head -n 100 ./file.txt will give you the first 100 lines.

vim in the command line buffers as you read through a file (it doesn't open it in one go) so it's quite effective too.

thelastshadow
  • 3,406
  • 3
  • 33
  • 36
19

You can install Midnight Commander.

Debian, Ubuntu, etc.:

apt-get install mc

Red Hat, CentOS, Fedora, etc.:

yum install mc

You can start Midnight Commander from the CLI with the mc command. After that you may select and open any file in "view mode" (F3) or in "edit mode" (F4).

mc is much more efficient when opening and browsing large files than vim. I checked it myself.

If you want to watch a very large file in your favorite editor, without worrying about the limitations associated with RAM, I suggest you split the file using the split command:

split -n 8 [FILE_NAME]

The above cammand splits the file into 8 parts.

Of course, this solution will only check for some applications. Note that not every file retains its consistency after the division (e.g. XML does not). It all depends on what you want to do with the given file.

simhumileco
  • 31,877
  • 16
  • 137
  • 115
4

If viewing is anything you need, you might want to use less which should be included with your distribution. I'm frequently viewing terabyte-sized files with it. There are also the variants of zless and bzless for gzipped/bz2'ed files.

emacs should also work with large files (as an alternative to vim).

nano is another vim alternative I find easier to use for basic tasks in the default configuration. In a short test run, I could successfully view a 1GB file, however opening it took more than 30 seconds (however after that, it seems to run quite smoothly).

Uli Köhler
  • 13,012
  • 16
  • 70
  • 120
1

I have just encoutered this very problem -- I need to view big log files. I tried gedit but it failed to open. Vim worked but I want to scroll. I also tried to install gglog but it does not provide the function of line wrapping and my logs are jsonlines so the lines are long and the wrapping is imporatant.

So finally, I unexpectedly discovered that it is the easiest to use a web browser. I checked both Firefox and Chromium. They work perfectly. I can scroll quite comfotably through my big logs and even search for words. So my advice is to use any decent web browser to view such files.

JenyaKh
  • 2,040
  • 17
  • 25
  • I don't know if it is wise to open a 4GB file in a browser. My chrome struggles if I open ~100 MB txt file. – MilMike Jun 29 '20 at 07:20
  • How do you open a file with web browser anyway? I have 1.7GB tsv (csv line just tab separated), so I drag and drop to Firefox and it wants to download the file – Pawel Cioch Oct 26 '21 at 15:04
0

Natpad handles opening big files pretty well. Natpad 2.5