Appending the line number and a seperator to each line of a file ?

Hi, I am a newb as far as shell scripting and SED goes so bear with me on this one.

I want to basically append to each line in a file a delimiter character and the line's line number e.g

Change the file from :-

aaaaaa
bbbbbb
cccccc

to:-

aaaaaa;1
bbbbbb;2
cccccc;3

I have worked out how to append the ";" to the end of each line ( sed '1,$s/$/;/') but am stumped with the line number bit :mad: .

This is on a Sun Solaris box btw.

Any help appreciated.

Thanks

Paul

nawk -v OFS=';' '{print $0, FNR}' myFile

Thanks very much vgersh99 :slight_smile: , works great.

$ sed = file | sed "N;s/\(.*\)\n\(.*\)/\2;\1/"
aaaaaa;1
bbbbbb;2
cccccc;3
$ sed -n "p;=" file | sed "N;s/\n/;/"
aaaaaa;1
bbbbbb;2
cccccc;3
cat -n filename |sed 's/\(.*\)\([0-9][0-9]*\)\(.*\)/\3;\2/'