Hi,
I (newbie shell scripter) have to write a script that will read parameter/value pairs used as configuration parameters for an application. The configuration file as the following form:
parameter1Name=parameter1Value
parameter2Name=parameter2Value
...
I'm looking for a more efficient way of reading through the configuration file in order to set script variables. I don't like the fact that I'm using the same grep twice...
Many thanks!
I (newbie shell scripter) have to write a script that will read parameter/value pairs used as configuration parameters for an application. The configuration file as the following form:
parameter1Name=parameter1Value
parameter2Name=parameter2Value
...
I'm looking for a more efficient way of reading through the configuration file in order to set script variables. I don't like the fact that I'm using the same grep twice...
Code:
if grep "^parameter1Name=" file.txt > /dev/null; then
# parameter1Name= is found in file.txt
aVar=`grep "^FOO=" file.txt | awk -F= '{ print $2 }'`
else
# FOO= is not found in file.txt
aVar="UNDEFINED"
fi
Many thanks!