The eval command reads and executes commands using the following format:
It causes commands to be expanded twice. For simple commands, there is no difference in execution with or without eval:
$ eval print ∼ /home/anatole
Here is a more complicated command that illustrates the use of eval. We want the contents of the stext file redirected when variable X is accessed.
$ cat stext She sells seashells by the seashore.
First, variable X is set to "<stext":
When the value of X is printed using simple variable expansion, it generates an error:
$ cat $X <stext: No such file or directory
Using the eval command, X is first expanded to <stext, then the command cat <stext is executed. This causes the ...