January 2001
Intermediate to advanced
480 pages
7h 22m
English
The eval command reads and executes commands using the following format:
eval commands
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":
$ X="<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 ...
Read now
Unlock full access