Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

share|improve this question

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

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

    
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
add comment

7 Answers

The question heading suggests head but your body

20 lines at a time

suggests more.

share|improve this answer
add comment

Try man head

head -- display first lines of a file

share|improve this answer
add comment

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

share|improve this answer
add comment

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.

share|improve this answer
add comment

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.
share|improve this answer
    
head -20 file answers the question, more useful is more, but the awk line looks, awkward. –  datasmid May 20 at 5:15
add comment

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.

share|improve this answer
add comment
most is the result of 20 years of fundamental research about advanced terminal paging techniques.
share|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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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