Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!samsung!noose.ecn.purdue.edu!iuvax!att!dptg!mtune!jrw From: jrw@mtune.ATT.COM (Jim Webb) Newsgroups: comp.unix.questions Subject: Re: KSH script arguments Summary: a bit long winded Message-ID: <768@mtune.ATT.COM> Date: 30 Aug 90 18:05:22 GMT References: <13160@hydra.gatech.EDU> Distribution: comp.unix.questions Organization: AT&T BL Middletown/Lincroft NJ USA Lines: 35 In article <13160@hydra.gatech.EDU>, gt0178a@prism.gatech.EDU (BURNS,JIM) writes: > in article , jonc@uts.amdahl.com (Jonathan Chang) says: > > How can I extract the last argument to a ksh script? > > I'll answer your question 2 different ways. ....and then takes 60 lines to do it. A bit long winded :-) And in article <858@iiasa.UUCP>, wnp@iiasa.AT (wolf paul) writes: > This works; whether it is the most elegant solution I don't know: > > LASTARG=$(eval "echo \$$#") > > Anyone know of a better way? Almost. You have to be careful if you have more than 9 arguments.... $ set a b c d e f g h i j k l m n o p q r s t u v w x y z $ eval "echo \$$#" b6 b6? yup.... it turns into echo $26, which is parsed as ${2}6. To get around this, one needs some more {}'s: $ eval echo \$\{$#\} z Still, very ugly :-) Any other takers on this one? Later, -- Jim Webb "Out of Phase -- Get Help" att!mtune!jrw "I'm bored with this....Let's Dance!"