bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Referencing last positional variable


From: Robert Mark Bram
Subject: Referencing last positional variable
Date: Fri, 22 Mar 2002 12:42:40 +1100

Howdy all!

I have a script in which I would like to access the last positional variable
directly (and I don't know how many paramaters will be issued).

I know I could do this:

# Go through arguments, storing the one
while [ "$#" -gt 1 ]
do
    shift
done
last=$1

But I want to try referencing it directly instead.

I have tried this:
numArgs=$#
lastArg=${numArgs}
echo $lastArg

numArgs=$#
lastArg=$`echo $numArgs`
echo $lastArg

But only got this output:
3
$3


How can I do this?

Thanks!

Rob

:)
:-}
;->





reply via email to

[Prev in Thread] Current Thread [Next in Thread]