You need to provide test for failure otherwise you will get some gibberish.
these are called positional parameters and there are 9 of them. To have more you need to use shift command.
There is no need to use awk here.
Another interesting construct for long file is:
cat filename | grep sdosanjh |
while read var1 var2 var3
do
echo $var1 $var2 $var3
done
If you have less variables than items, all remainder of the read line gets packed into var3
This is how it should be done in this particular case. Mine just illustrates, for less experienced, the fact that you can chain several commands before that while.
There is a problem with this construct. Theoretically this should work all the time, but it does not. When I use Solaris sh, in some releases this works and in some it does not. This is why I did not recommend it. I guess QC at Sun is not what it used to be. I wonder which other OS this is not working. This is also warning for people moving scripts around. At the same time in ksh it works fine in the same OS. Around Solaris 6 or 7 this forced me to rewrite half of my scripts.