I need to number the lines in my text file. I know how to do this with standard numbering (1,2,3,4, etc) but I need to count in multiples of 5, beginning 0,5,10,15...
example existing file:
abcd
efg
hijklm
nopqrs
desired output
0 abcd
5 efg
10 hijklm
15 nopqrs
etc.
Please advise. Can I use awk? Crucially it MUST begin with 0!
Thanks RudiC, I have gone through the man page for nl
and able to understand the command now.
-v Number
Sets the initial logical-page line number to the value specified by the Number variable. The default value of the Number variable is 1. The range of the
Number variable is from 0 to 32767.
-i Number
Increments logical-page line numbers by the number specified in the Number variable. The default value of the Number variable is 1. The range of the
Number variable is from 1 to 250.
-n Format
Uses the value of the Format variable as the line numbering format. Recognized formats are:
ln
Left-justified, leading zeros suppressed
In that expression, string concatenation has highest precedence, so, firstly, 5" "$0 is joined. Then, while converting the just-concatenated string to a numeric, += truncates it at the first space, discarding the entire record, $0.
Your suggestion is equivalent to $0=i+=5 . Aside from the discarded data, this generates an arithmetic sequence which begins at 5, not 0.