executing a variable assignment in a string

I'm using whatever the scripting is in this copy of busybox ! So not the full boxed set sometimes.

If I do

cmd="echo fred"
$cmd

the system prints "fred"

if I do

cmd="fred=9"
$cmd

it barfs.

Is there a simple way to put a varabble assignment in a string and execute it?

David

Try:

cmd="fred=999"
eval $cmd
echo $fred
1 Like

Thanks

I knew I'd seen it done somewhere.... just couldn't google how!

TVM