eval_tutorialspint

eval [arg...]

  • Eval command can execute than command stored in the string

Example

# example1
$COMMAND="ls -lrt"
$eval $COMMAND

#example2

$ a=10
$ b=a
$ c='$'$b (note : The dollar sign must be escaped(转义)with '$')
$ echo $c
------
$a
---------

$eval c='$'$b
$ echo $c
output:
10