Software >> OS >> Unix >> Solaris >> Shell >> How to execute a command stored in a string from within a script

Example :

user=foo

cmd="useradd -m -d /export/home/$user -g staff $user"

eval $cmd