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

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

jquery - SimpleModal Confirm fails to submit form -