How to display line numbers in 'less' (GNU)

前端 未结 6 1843
余生分开走
余生分开走 2021-01-29 17:09

What is the command to make less display line numbers in the left column?

6条回答
  •  南笙
    南笙 (楼主)
    2021-01-29 17:46

    If you hit = and expect to see line numbers, but only see byte counts, then line numbers are turned off. Hit -n to turn them on, and make sure $LESS doesn't include 'n'.

    Turning off line numbers by default (for example, setting LESS=n) speeds up searches in very large files. It is handy if you frequently search through big files, but don't usually care which line you're on.

    I typically run with LESS=RSXin (escape codes enabled, long lines chopped, don't clear the screen on exit, ignore case on all lower case searches, and no line number counting by default) and only use -n or -S from inside less as needed.

提交回复
热议问题