Finding the last arg

Stuart Poulin stuart at amc-gw.amc.com
Sat Jan 5 12:28:23 AEST 1991


Of course if you know the last arg will never have white space and
the command line wont have args like "=", you can use expr:
	Last=`expr "$*" : '.* \(.*\)' \| "$*"`

	-or-
Use awk, it can handle a "=" by itself but still no white space.
	Last=`Last=`echo "$*" | awk '{ print $NF }'`

    -or-
Something with sed or grep. 

I like the "for last do :; done" method - it's very clever and always works. 

Stuart Poulin                             DNS: stuart at amc.com
Applications Engineer/System Administrator
Applied Microsystems Corporation         UUCP: amc-gw!stuart
Redmond, Washington  98073               Dial: 800-ASK-4AMC,206-882-2000 



More information about the Comp.unix.shell mailing list