Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!telxon!ping!gorpong From: gorpong@ping.uucp (Gordon C. Galligher) Newsgroups: comp.unix.wizards Subject: Re: evaluating ${10} and above in sh/ksh Summary: No, you must put shell through hoops Keywords: sh, ksh, eval Message-ID: <1990Aug14.033614.12834@ping.uucp> Date: 14 Aug 90 03:36:14 GMT References: <514@risky.Convergent.COM> Organization: The 23rd. Century Lines: 46 In article <514@risky.Convergent.COM> chrisb@risky.Convergent.COM (Chris Bertin) writes: >There doesn't seem to be a way, in sh or ksh, to evaluate $10 and higher. >$10 and higher are evaluated as ${1}0, ${1}1, etc... > instead of ${10}, ${11}, etc... >I have tried many different ways and they all fail. Do you know one >that will work? I realize this is hardly what you wish to read, but the only way to gain access to the others is by using 'shift' to get them. You could, on the other hand set up a loop to grab all of them into your own variables: argv0=$0 start=1 pred=argv for i do eval "${pred}${start}='$i'" # Be sure to quote the $i !! start=`expr $start + 1` done argc=`expr $start - 1` This would give you variables $argv0, $argv1, $argv2 up to and including $argv$argc. To simply print them out: echo " 0 - $argv0" start=1 while [ $start -le $argc ] do echo " $start - `eval echo '$'${pred}${start}`" # Yes, ugly start=`expr $start + 1` done No, it is not pretty, but it is workable. There may not be many times you would want to print option 'x' without knowing what 'x' was. If you always wanted to check the first option, then it is just $argv1. If you find yourself always parsing through the command line options, then you should probably put a case inside of the for and then do with them what you will. -- Gordon. -- Gordon C. Galligher 9127 Potter Rd. #2E Des. Plaines, Ill. 60016 telxon!ping%gorpong@uunet.uu.net (not tested) (Is this even legal??) ...!uunet!telxon!ping!gorpong (tested) (And it works!) "It seems to me, Golan, that the advance of civilization is nothing but an