0

On linux more -10 <file> displays only 10 lines at a time of file file. On a macOS Terminal, however, this does not work (for me).

How can I get this to work? Or how else can I get equivalent behaviour with less?

I should say that I run OSX 10.12.5.

1

more -10 is a GNU extension, not standard. more -n 10 will work anywhere—whether with GNU more or BSD or any implementation of POSIX more.

Use more -n 10 filename.

4

less -10 <file> on macOS 10.13 also scrolls forward 10 lines at a time. The major difference is that it fills the first screen, as opposed to more which only generates the specified number of lines even on the first screen.

If that's not acceptable, the LINES env variable can override the number of lines on the screen. So something like

env LINES=10 less <file>

will force 10 lines on the first screen, and also scrolls forward 10 lines at a time.

  • Okay, but I'm on OSX 10.12.5. less -10 filename does not work, but setting the environment variable LINES does. However, that is not quite what I want (because it sticks). Also, less output doesn't stay after the command is finished. – Walter Sep 29 '17 at 18:31
2

You can type 'head -10 filename' OR:

You can type more filename which will fill screen first time. After that type a number before hitting space to specify the number of lines on the 2nd scroll. You have to type a number each time to keep scrolling thru the file.

  • Sorry, doesn't work for me. Also, I only want to see the first n lines. – Walter Sep 29 '17 at 18:32
  • 1
    @Walter You can use 'head -10 filename' to get only 1st 10 lines. – jmh Sep 29 '17 at 18:47
  • If you convert that comment to an answer, I'll accept it. – Walter Sep 30 '17 at 17:19
  • @Walter I edited my answer to the answer you used. Thanks – jmh Sep 30 '17 at 22:51
  • Why the -10 on this answer?? The OP liked it and was going to give me credit! – jmh Oct 12 '17 at 19:40

You must log in to answer this question.

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