| Ed Morton 2005-03-28, 6:18 pm |
|
stevenbentley@yahoo.com wrote:
> Hi again,
> I have a variable that contains
> VAR1='one "two three" four' and i would like to store these in the
> following
>
> VAR2=one
> VAR3="two three"
> VAR4=four
>
> I have the following:
>
> VAR1='one "two three" four'
> echo ${VAR1} | awk '{ print $2 }'
PS1> VAR1='one "two three" four'
PS1> echo "${VAR1}" | awk -F\" '{ print $2 }'
two three
PS1> echo "${VAR1}" | gawk 'BEGIN{RS="\""}$1=$1'
one
two three
four
PS1> eval `echo "${VAR1}" |
gawk 'BEGIN{RS="\""}$1=$1{printf "VAR%s=\"%s\"\n",NR,$0}'`
PS1> echo "$VAR1"
one
PS1> echo "$VAR2"
two three
PS1> echo "$VAR3"
four
> but as I'm sure you reliase i get: "two
> Is this the best method (with fixes!) or ...?
>
> I'm having real problems with quoting at the moment!!!
Hope that helps,
Ed.
|