[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

escaping arithmetic during evaluation

From: Matt P.
Subject: escaping arithmetic during evaluation
Date: Thu, 07 Feb 2002 21:20:01 -0500
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv: Gecko/20010901

I've just received a solution to my previous posting

"i have a variable, eg NAME, and based on the value of that variable i
would like to create other variables. For example, if NAME=chet, I would
like to create eg chet.meal=pizza. "

The solution, kindly suggested by Paul <address@hidden> goes like that:
assignment: eval "${NAME}_bday="'"$BDAY"'
evaluation:   eval 'echo "$'"${NAME}"'_bday"'

This solution works most cases, except when NAME contains a special character, eg -, as in john-doe.

I have tried a couple of solutions with a \ to escape the -, but I was unsuccessful.

I would appreciate any suggestion regarding this question



PS Is there an archive somewhere? I came from www.gnu.org/directory/bash.html, and couldn't find an archive.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]