help Needed for READ command.....

Hi UNIX BONDS,
My requirement is that i want to use READ as
while read a x y z
do
some logic
done < dummy_file.txt

But the requirement is that the number of columns in the file dummy_file.txt is not fixed.
So "while read a x y z" may work fine if there are four columns, but how do i decalre variables when the columns may keep on varying.

Basically i dont want to hard code the number of columns as done above...

Thanx in advance......
Regards,
rahul26 :slight_smile:

It's not a solution Rahul but a hint. I remeber telling you about NR of awk. You can use this do create a dynamic line for your while statement. Just try it yourself, it will help you in learning concepts.

regards
Apoorva Kumar

will something like this help you to proceed !!!

>cat dump.dat

abcde 123
abcde 234 567
abcde

>awk '{ for(x=1; x<= NF; x++) { print x " : " $x } }' dump.dat

1 : abcde
2 : 123
1 : abcde
2 : 234
3 : 567
1 : abcde