Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Echoing the last argument ???

Status
Not open for further replies.

rogsal

Programmer
May 12, 2004
10
0
0
SE
Hi!

I just run into a small problem....
My script takes som parameters and at the end a filename
Is there a simple way to echo that last argument??

I tried different variations of echo "${$#}"
but it doesn't work

all help is useful...
/Roger

ps. my workaround is a loop with a shift statement but I would like a nicer method
 
I can't come up with anything better than
Code:
for i in $@
do
  fname=$i
done
which isn't that different to your shift loop.

Columb Healy
Living with a seeker after the truth is infinitely preferable to living with one who thinks they've found it.
 
Hi:

I'm not near a unix terminal, but this should work for the ksh:

lastarg=$(eval echo \$$#)

Regards,

Ed
 
You may try something like this:
eval lastarg=\$$#


Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top