Hi i would like to add line numbers to end of each line in a file.
I am able to do it in the front of each line using sed, but not able to add at the end of the file.
Can anyone suggest
The following code adds line number to start of each line
sed = filename | sed 'N;s/\n/\t/'
If you are using two sed scripts anyway, it's not very hard.
sed = filename | sed -e 's/^\([1-9][0-9]*\) *\(.*\)/\2 \1/'
My version of sed puts the line number on a separate line with the = command, not on the same line, so this script doesn't actually work for me. This might be easier and more efficient with a simple awk or perl script, anyway;
There is a number of reasons why line numbers are traditionally printed at the beginning rather than the end of lines, though. Perhaps it would be wiser to stick to the traditional format.