I have a text file called "shoplist.txt" which one have:
drinks water cola fanta fruit banana orange
And I want to get how many items per line I have. I'm able to extract drinks and fruit with function "cut" but how can I count how many words I have in each line?
My actually code is:
fileLine=`cat file.txt` #Here I get each line saving it to fileLine for line in $fileLine; do echo ((aux++)) done
But this code dosen't work because it save to %fileLine each work (drinks, then water,then cola,...)
How can I get the first line and then count the words on that line?