May 2000
Beginner
761 pages
18h 20m
English
The eval command evaluates a command line, performs all shell substitutions, and then executes the command line. It is used when normal parsing of the command line is not enough.
1 $ set a b c d 2 $ echo The last argument is \$$# 3 The last argument is $4 4 $ eval echo The last argument is \$$# The last argument is d 5 $ set -x $ eval echo The last argument is \$$# + eval echo the last argument is '$4' ++ echo the last argument is d The last argument is d |
Explanation
Four positional parameters are set.
The desired result is to print the value of the last positional parameter. The \$ will print a literal dollar sign. The $# evaluates to 4, the number of positional parameters. ...
Read now
Unlock full access