Hi all,
I have a variable say var1 (output from somewhere, which I can't change)which store something like this:
echo $var1
name=fred
age=25
address="123 abc"
password=pass1234
how can I make the variable $name, $age, $address and $password contain the info?
I mean do this in a simple way rather than
for line in $var1
do
varname=`echo $line | cut -f 1 -d '='`
varvalue=`echo $line | cut -f 2 -d '='`
eval $varname=$varvalue
done
I am looking for something like
. $var1 #I know it is wrong
and then...
echo $name # fred
echo $age # 25
echo $address # 123 abc
echo $password #pass1234
I cannot cat $var1 > tmpfile
. tmpfile
rm tmpfile
because the var1 contain sensitive info e.g. password
Thanks a lot!