0

I am on Mac OS. I have a C++ program that generates 1000+ lines of data that I redirect to a file. I then use less / more to go through the file. I'd like to have less pause at user-defined chunks of data instead of of pausing every screenful. I thought I could use the ^L character to mark page breaks, but even after adding them in my C++ code with

        printf("control-l \n");

the less command on my Mac will still pause at every screenful instead of at each control-L.

I remember from decades ago that this worked on Unix. Do I need to do something different here?

3
  • Why would your code do a ^V before the ^L ? That's not what the binary stream would expect. Sep 17, 2021 at 3:03
  • The ^V is to allow my vi editor to accept the next character as a ^L. I'll remove it. It's confusing. Sep 17, 2021 at 3:43
  • more typically does this, but not less. The current util-linux version of more pauses at formfeeds by default; perhaps the macOS version behaves differently... Sep 17, 2021 at 5:14

2 Answers 2

1

Not a page break, but the 'u' and 'd' keys can be set to scroll the screen however many lines you want. By default, pressing these keys scrolls the file by half a screen 'u'p and 'd'own. But if you type a number before pressing either key, both keys will start scrolling the file by the number of lines you specified.

less file:
  10d ; scrolls the file down 10 lines
  d   ; scrolls the file down another 10 lines
  u   ; scrolls the file up 10 lines
  25d ; scrolls the file down 25 lines
  d   ; scrolls the file down 25 lines
  u   ; scrolls the file up 25 lines
  5u  ; scrolls the file up 5 lines
  d   ; scrolls the file down 5 lines

Note: I'm using the GNU version of less on Debian Linux. The Mac version could be different.

1
  • The Mac version behaves the same. Sep 21, 2021 at 9:55
0

less doesn’t pause at formfeeds, but you can achieve the same effect by searching for them: / CtrlV CtrlL Enter. Press n to jump to the next formfeed, or N to go back to the previous one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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