version 1.0.0, 2013-10-19 : Initial version
Add line numbers while printing a file line nl command
Perl one-liners to print out the line numbers at the begining of each lines while printing the line.This shell command prints out the lines of the input, preceeding it with the line numbers, like the nl command do.
perl -pe 's//$. /' input
If you want exactly the same output than nl
(meaning the same spacing at the
begining of the line with a right-aligned line number), you can also use this
command:
perl -pe 'printf "% 6d ",$.' input