somebody knows the command to make less display line numbers in the left column?
+4
A:
You could filter the file through cat -n
before piping to less
:
cat -n file.txt | less
Or, if your version of less
supports it, the -N
option:
less -N file.txt
Greg Hewgill
2009-05-06 20:55:43
+7
A:
From the manual:
-N or --LINE-NUMBERS Causes a line number to be displayed at the beginning of each line in the display.
dirkgently
2009-05-06 20:56:49
When I less a huge file then "G" to the bottom, it says "Calculating line numbers... (interrupt to abort)" even though it is not displaying line numbers. I'd like to know how to find out what line I'm on without exiting and relaunching with -N. I'm suffering the penalty. Where's the reward?
Richard Bronosky
2009-08-04 16:23:26
wow, I have looked at the help for less dozens of times hoping to find the answer to this. I have always overlooked "-<flag> Toggle a command line option [see OPTIONS below]." ...which means you can type "-N" from within less. I have been annoyed by this for about a decade. Good times!
Richard Bronosky
2009-08-04 16:33:46
you can type `-N` (show) and `-n` (hide) from within less to toggle line numbers.
rcoup
2010-05-17 01:15:45
+1
A:
You can set an enviroment variable to always have these options apply to all less'd file
e.g.
export LESS='-RS#3NM~g'
sgargan
2009-10-15 21:15:56
+1
A:
Command line flags -N
or --LINE-NUMBERS
Causes a line number to be displayed at the beginning of each line in the display.
You can also toggle line numbers without quitting less by typing -N<return>
. It it possible to toggle any of less's command line option in this way.
Matthew Jaskula
2009-11-06 15:09:00
Passing -N or --LINE-NUMBERS only shows the date for me in CentOS 5.3. However using -N after starting less works fine.
Mike Miller
2010-03-22 14:19:32