1. Eval command-line
whichCommand- Lineis a normal command line typed on the terminal. But when you put it in front of it, EvalThe result is that the shellscan it two times before executing the command line. such as:
Pipe= "|"
Eval ls $pipe wc-l
shell 1 When the command line is scanned, it replaces the pipe < Span style= "Font-family:times New roman;word-wrap:break-word" >eval Let it scan the command line again, when shell | as a pipe symbol.
If the variable contains any required Shell characters you see directly on the command line (not the result of a substitution), you can use the eval . command line terminator (; | & ),I /o Redirection (< > ) and the quotation marks belong to the Shell symbols that have special meanings must appear directly on the command line.
2. Eval echo \$$# to get the last parameter
such as: Cat Last
Eval echo \$$#
./last one, three four
four
After the first scan, shell Shell When the row is scanned again, it replaces the $4 echo command
3. The following shows how to use eval command creates a pointer to a variable:
x=100
Ptrx=x
eval echo \$ $ptrx Point to b
100&NBSP; print Span style= "Word-wrap:break-word" >100
eval $ptrx =50 will 50 save to ptrx
Echo $x
- Print -
Use of the Linux command eval