how to print out line numbers of a text file?

i have this text file name test.txt which contain :
aaaaa bbb
iiiiiiiiiiiii ccf
ddaaa ddd

and i need a script that can print out the line numbers using a while loop..
so when the script is run..it will have this:
1
2
3

any ideas? :slight_smile: thanks guys

I think the below sed command will help you

sed -n '=' datafile

thanks again for great help! solve part of my problem already..thanks...

cat -n <filename>|awk '{print $1}'

should help

thanks very much!