When navigating log files with less (e.g., using Space and B), sometimes I run into extremely long lines, as in 120,000 characters long long. It gets slow to navigate around these, I guess because it has to figure out what can go in the terminal and where to put the line breaks.

Everywhere else in my log files the lines are only wrapped at the very most maybe 10 times, never more than a page, that's for sure. So I don't want to do something drastic like not wrap the file.

Is there a way to go to the end of these lines when I hit them?

  • 1
    You can always enter -S to disable line wrapping (or start less as less -S) – Stéphane Chazelas Jan 26 '16 at 16:25
  • @Stephane Right, but a lot of my lines are longer than the width of the console and only these really long ones are problematic, and they are quite rare. – Captain Man Jan 26 '16 at 16:28

Originally I tried /\n, but the correct way to find end-of-lines is /$. (Remember, in regex ^ is the start of the line and $ the end, \n finds the n's.)

In case you are navigating up, use ?^ instead, this skips to the start of the line.

  • 4
    See also &!.{1000} to filter out lines of more than 1000 characters. – Stéphane Chazelas Jan 26 '16 at 17:16

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.