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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Saving value of last argument into a variable

Status
Not open for further replies.

Maldini

Technical User
Nov 10, 2002
55
GB
Simple thing really, I have this script that I've written where I can have a different number of options input.

I need to find what the last argument input to this script by the user and then save its value into a script variable.

This is what I have and it manages to get the value and then output it onto stdout.

Code:
eval echo \$$#

Any way to twist this around so it saves into a variable in my script?

Many thanks.
 
Hi:

If you're running ksh you this works:

xvar=$(eval echo \$$#)

Regards,



Ed
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top