Getting the last argument passed to a shell script -
$ 1
is the first argument.
$ @
is all of them
How can I find the last argument in a shell script?
This is a bit of hack:
for the last; True; <$ Code = $ echo $ last
This is a very portable (again, should work with bash, ksh and sh) and does not change the arguments, which can be good is.
It uses the fact that for the the
logic actually has a rigidity if you do not tell it what the loop is, and the fact is that for loop variables Not scotched: They are the last value they set.
Comments
Post a Comment