The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 04-28-2008
bisla.yogender bisla.yogender is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 30
Question How print number

Hi,

I am using for loop as follow:

for n in `ls`
do
echo "$n"
done

The code is running fine and aI am getting valid output as:
jick
zenny
assi
yogi


But 1also want to print count in front of each output like this:

1 jick
2 zenny
3 assi
4 yogi

What should I add in my logic for achiving this?

Kinly advise.

Regards,
Yogi