Viewing a large text file

Asked by ant

Hi, i have a 3.8GB text file and i cant view it with anything (except using the command 'more' but due to the size of the file and how often ill need to switch between looking at the start and end this isnt much use!) . Are there any programs i can download which will allow me to view this file?

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu gnome-terminal Edit question
Assignee:
No assignee Edit question
Solved by:
Andrea Corbellini
Solved:
Last query:
Last reply:
Revision history for this message
Andrea Corbellini (andrea.corbellini) said :
#1

Hehe, interesting problem!
You cannot view the file with standard editors because the file is loaded in RAM and in swap if needed. `more` reads the file line per line but it cannot go back.
I don't know any program that can solve the problem, but I know 2 ways:
1. Cutting the file: with `more` you can keep the sections you need and store them in a separate file.
2. Creating a script: the simplest way is using Python, if you don't know any programming language, I can do the work for you.

Revision history for this message
Best Andrea Corbellini (andrea.corbellini) said :
#2

Sorry, I forgot `less`! Instead of `more` use `less`!

Revision history for this message
marcobra (Marco Braida) (marcobra) said :
#3

You can try the head and tail command
man head
man tail

Example:
head -100 /var/log/dpkg.log | less
tail -200 /var/log/dpkg.log | less

HTH

Revision history for this message
ant (s0346312) said :
#4

Thanks Andrea Corbellini, that solved my question.