samedi 29 novembre 2014

for loop not working for multiple lines


I have a array like this "Apple Banana Clementine Date"


I have to print like this:



1. Apple
2. Banana
3. Clementine
4. Date


Script file:



for i in "${fruits[@]}"; do
echo "$lineno. $i "
lineno+=1
done


output of myscript:



1. Apple
Banana
Clem....


I don't understand why it is not printing lineno and also why it is printing long gap b/w 1. and Apple. Thanks.



Aucun commentaire:

Enregistrer un commentaire