Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!zaphod.mps.ohio-state.edu!sdd.hp.com!elroy.jpl.nasa.gov!decwrl!sgi!shinobu!odin!thestepchild!rhartman From: rhartman@thestepchild.sgi.com (Robert Hartman) Newsgroups: comp.unix.shell Subject: Re: Positional parameters beyond $9 Message-ID: <1991Apr17.000302.11491@odin.corp.sgi.com> Date: 17 Apr 91 00:03:02 GMT References: <991@dri500.dri.nl> <1998@quando.quantum.de> Sender: news@odin.corp.sgi.com (Net News) Organization: Silicon Graphics, Inc., Mountain View, CA Lines: 52 In article <1998@quando.quantum.de> omerzu@quantum.de (Thomas Omerzu) writes: > >In article <991@dri500.dri.nl> slootman@dri.nl (Paul Slootman) writes: > >[...] >>not seen before. If a script has more than 9 positional parameters, >>there seems to be no way to *directly* access the tenth onwards. Try >[...] >>other way. Nothing in TFM states anything about problems with more >>than 9 parameters (unless I've overlooked it...) > >Quote from sh(1): > > Parameter Substitution > The character $ is used to introduce substitutable > parameters. There are two types of parameters, positional > and keyword. If parameter is a digit, it is a positional >. ^^^^^ > parameter. Positional parameters may be assigned values by > set. Keyword parameters (also known as variables) may be > assigned values by writing: > > >digit != number :-) There isn't any way to do that directly. However, I've never encounterd a case where I wanted to get at $10 without also wanting to (or being willing to) get at $1-$9. Here's an example of how I get at each argument in turn: while [ $# -gt 0 ] ; do case $1 in -*) options="$options $1" ;; *) files="$files $1" ;; esac shift done I suppose you could combine this with some sort of test to get at $10: tmp="$@" #capture args list in temp variable while [ $# -gt 0 ] ; do if [ `expr $# - 10` -eq 0 ] ; then arg10="$1" ; fi shift done set $tmp #restore original args list Or you could use your favorite counting look and stick a shift command in there. But for handling a variable argument list, I like the first option best. -r