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

Is there an open source WebSockets (JavaScript) XMPP library? -

java - Is there an object like a "Set" that can contain only unique string values, but also contain a count on the number of occurrences of the string value? -

mysql - Can mysql_pconnect be called multiple times in one php page? -