Public feed #533135

Something

public text v1 · immutable
Raw Edit
·published 2007-06-03 10:59 UTC
rendered paste body
Bracket notation for positional parameters leads to a fairly simple way of referencing the last argument passed to a script on the command line. This also requires indirect referencing.

args=$#           # Number of args passed.
lastarg=${!args}
# Or:       lastarg=${!#}
#           (Thanks, Chris Monson.)
# Note that lastarg=${!$#} doesn't work.