glebspy
asked on
first second third words in a line
Hi -
I have a file params.txt which looks like
a b c
d e f
g h i
j k l
etc. , with 3 words per line.
I want to run the programme prog multiple times in a unix loop so that it runs
prog -option1 a -option2 b -option3 c
prog -option1 d -option2 e -option3 f
etc.
Please tell me an easy way of writing this loop (if there is one).
I have a file params.txt which looks like
a b c
d e f
g h i
j k l
etc. , with 3 words per line.
I want to run the programme prog multiple times in a unix loop so that it runs
prog -option1 a -option2 b -option3 c
prog -option1 d -option2 e -option3 f
etc.
Please tell me an easy way of writing this loop (if there is one).
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
while read arg1 arg2 arg3
do
prog -option1 $arg1 -option2 $arg2 -option3 $arg3
done < params.txt
(Of course, if one of the lines has more than 3 entries, arg3 will be everything up to the end of the line...)