up vote 1 down vote favorite
share [g+] share [fb]

Can you guys help me? I can't remember the terminal command to open a large text file, but only display (for example) 20 lines at a time. The reason for this is I am trying to read a 1.3gb error log file. Can somebody help me with the right command?

Thanks

link|improve this question
Hmm, how is this SO rather than SU (or SF since it's an error log)? Honestly wondering. – kb. Feb 15 '10 at 7:48
@kb Bash scripting == programming? :) – artemb Feb 15 '10 at 7:53
1  
@artemb, it's a long-established precedent that bash scripting is programming. However, I tend to think this is more of a superuser question since it's more about how to view a file than how to write some code in bash. – paxdiablo Feb 15 '10 at 8:02
@artemb ah, thanks, i didn't figure that it was in a scripting context but ok, yes i guess it actually fits :D – kb. Feb 15 '10 at 11:15
feedback

migrated from stackoverflow.com Feb 16 '10 at 0:32

This question came from our site for professional and enthusiast programmers.

7 Answers

The question heading suggests head but your body

20 lines at a time

suggests more.

link|improve this answer
feedback

Try man head

head -- display first lines of a file

link|improve this answer
feedback

head -10000 bigfile.log | tail -20 should display 20 lines around the 10000th line.

link|improve this answer
feedback

Try less filename.

It suits your requirement of windowing about 20 lines of a large file. A full description can be obtained with man less.

link|improve this answer
feedback

Try less. It displays a few lines at a time, but allows you to scroll.

less yourfilename

Read the manual for less for more info.

link|improve this answer
feedback

you can use head, less, more ,and awk

$ awk 'NR%20==0{print;getline <"-"}NR{print}' file

$ more -20 file

$ head -20 file # but only shows 20 lines and doesn't scroll.
link|improve this answer
feedback
most is the result of 20 years of fundamental research about advanced terminal paging techniques.
link|improve this answer
Downvoted? why ? There is a tool called "most", which was developped after "more" and "less" which is pretty awesome. – MatthieuP Mar 28 '11 at 14:04
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.