Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

The question heading suggests head but your body

20 lines at a time

suggests more.

share|improve this answer

Try man head

head -- display first lines of a file

share|improve this answer

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

share|improve this answer

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

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

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. – bbaassssiiee May 20 '14 at 5:15
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
    
Perhaps give a link? Also, don't have all of your text in code format – Roman Jan 5 at 13:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .