Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a Python script that is run like this:

scriptname --param_a=123 --param_b=423 --param_c=xyz

The script expects to be passed three parameters

I have a (configuration) text file, that contains the parameters. I want to write a Bash script (my first), that will use the entries in the file to pass the parameters to the script.

For example if the configuration text file contains the following data:

--param_a=123 --param_b=423 --param_c=xyz
--param_a=203 --param_b=343 --param_c=abz
--param_a=976 --param_b=891 --param_c=abc

Then I want to call the script (3 times) once for each line in the config file, and pass the parameters to the script.

Can anyone suggest how to write such a Bash script.

I intend to run the script on an Ubuntu system

share|improve this question
up vote 3 down vote accepted
while read -r -a array
    scriptname "${array[@]}"
done < configfile


while read -r line
    scriptname $line
done < configfile

The advantage to the first one is if your config file had commas, for example, between the parameters instead of spaces:


you could do:

while IFS=, read -r -a array
share|improve this answer
wow - thanks! – Takashi Dec 6 '10 at 18:18

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.