eval last=\$$#
echo $last
> -----Original Message-----
> From: Alexy V. Khrabrov [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, April 25, 1999 10:43 PM
> To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject: the last parameter in bash
>
>
>
> Now, just to distract the honorable gurus from holding their
> mailboxes empty,
> a bash programming contest. The winner gets life-time
> membership in 1unix.org!
>
> The Problem:
> Find the shortest, most intuitive, and most elegant way to
> extract the LAST parameter
> passed to a bash shell script. An example when it may be necessary is
>
> gcc -c -I/home/include -I/usr/local/include file.ads
>
> -- you don't know the number of the parameters but need only
> the last one.
>
> My solution:
> -----last begin:
> for last do a=0 # a=0 means "do nothing!"
> done
> echo $last
> -----last end.
>
> This is almost fine, except I'd rather refer to it as in
> history, directly, !$,
> and I also hate the a=0 dummy statement -- is there an
> explicit null statement in bash,
> such as ; by itself in C? However, a=0 is good since it
> doesn't invoke any programs.
>
> I dare y'all for a better solution! :-)
>
> (I tried to use $# for direct indexing, like ${$#}, but it fails.)
>
> --
> Cheers,
> Alexy Khrabrov -- www.suffix.com -- Segmentation f%^(&
> -
> To unsubscribe from this list: send the line "unsubscribe
> linux-net" in
> the body of a message to [EMAIL PROTECTED]
>
-====---====---====---====---====---====---====---====---====---====---====-
to unsubscribe email "unsubscribe linux-admin" to [EMAIL PROTECTED]
See the linux-admin FAQ: http://www.kalug.lug.net/linux-admin-FAQ/