eval invokes a set of arguments as a command sequence. It is useful when you need the arguments to be expanded twice.
#( Try the following ) var=value #( Set the variable cmd to hold a command to run later) echo -e "Enter a command to run \c"; read cmd #( When prompted, enter echo $var ) echo $var #( Now reference the variable at the prompt and press [enter]) $var #( The echo will run but it will print out $var) #( Repeat this, except use eval to run it ) eval $var #( Now the contents of var will be printed ) |
At the prompt, we could have just assigned the echo $var to an alias.