Hi,

I am trying to parse a set of space separated values from a file into an
array in a bash script. Thing is my individual values can also have spaces
between them hence each value is enclosed in double quotes. But the problem
is i am unable to parse them properly into an array.

After a bit of effort my problem boils down to the difference between
following 2 scenarios.

$> TESTARR=("abc def" ghi)
$> echo ${TESTARR[0]}
$> echo ${TESTARR[1]}

This correctly prints:
abc def
ghi

However
$> TESTARR=(`echo \"abc def\" ghi`)
$> echo ${TESTARR[0]}
$> echo ${TESTARR[1]}
This incorrectly prints:
"abc
def"


I guess i am missing something very basic. I would be glad if you could
suggest the correct way/way out.


-- 
Puneet
http://sahyog.blogspot.com/
Latest Post: Tutorial on SVN setup and usage
_______________________________________________
ilugd mailinglist -- ilugd@lists.linux-delhi.org
http://frodo.hserus.net/mailman/listinfo/ilugd
Next Event: http://freed.in - February 22/23, 2008
Archives at: http://news.gmane.org/gmane.user-groups.linux.delhi 
http://www.mail-archive.com/ilugd@lists.linux-delhi.org/

Reply via email to