Can someone please help.
I need to add a sequence number to the start of each line of a file.
It needs to be 6 characters long. ie 000001 next line starts 000002 etc.
Can someone please help.
I need to add a sequence number to the start of each line of a file.
It needs to be 6 characters long. ie 000001 next line starts 000002 etc.
nl -nrz oldfile > newfile
Thew default width is usually 6, you change it with
nl -w n
where n = width in characters
Thanks for that.
Its putting out a ^I after the line number. Is it possible to remove this?
Thanks
'man nl'
-ssep sep is the character(s) used in separating the line
number and the corresponding text line. Default sep is
a TAB.
You can do like this:
awk '{ printf ("%.6d %s\n", NR, $0) }' oldfile > newfile