Solved script to get parameter values from file

January 11, 2013 at 01:38:14
Specs: Mac OS X Lion 10.7.3
I have a file having parametrs as below
unix> cat file.txt
description=keep smiling always good for health

My requirement is :I have one shell script ,In that script ,I need to get the value of parameters name ,description .

See More: script to get parameter values from file

Report •

January 11, 2013 at 11:15:09
✔ Best Answer
Since your file is the structure of, command=var, all that needs to be done is perform an eval on a string containing an export command. What complicates this is the fact that the description does not contain beginning and ending double quotes as such:

description="keep smiling always good for health"


while read myline
   eval "export \"$myline\""
done < file.txt
echo "$name"
echo "$description"

Report •
Related Solutions

Ask Question