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.
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.
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
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.
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.
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).
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.