/bin/sh

Chris Torek chris at mimsy.umd.edu
Tue Jan 16 10:53:32 AEST 1990


In article <620 at dr.uucp> thormod at dr.uucp (Thormod N{ringsrud) writes:
>I often have a need to pick up the last parameter $1, $2 .. from
>the parameter list.

It looks like `eval $"$#"' would do it:

	$ set foo bar baz
	$ eval echo $"$#"
	baz

but for a small problem with sh argument syntax:

	$ set a b c d e f g h i j k l
	$ echo $11
	a1
	$

`$11' means `${1}1', and not ${11}.  (Trying `${11}' directly gives
`bad substitution'.)

The only reliable way to get at the last parameter is something like

	for i do last="$i"; done
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at cs.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.unix.questions mailing list