Is there a limit to the no. of arguments to a shell script ?

What is the maximum no. of arguments that could be passed to a shell script ? Is there any restriction ?

I've a requirement where I need to pass a list of names to a unix script and I guess the number of such names is not a fixed one. It can run into hundreds.
Is this feasible ?

yes - should be possible.

have a look at the shift shell built in....i.e. man shift

should be what you want.

Yes there's a limit to the max no. of arguments you can pass to a command.
Its system dependent I think. Try this:

$ getconf ARG_MAX

Agreed with Tyatalus that it is system dependent. But tried on posix and bash shell , and the maxmium number of arguments you can pass to a script is 9. If you want to pass more parametrs , you need to use the shift function.

The intresting thing is , more than 9 parameters works fine if numbers are given , but gives unexpected output when tried with letters.

So if you are using some other shell, try testing it with letters.

Thanks!
nua7

Hi.

Some shells allow access to script parameters using syntax as follows:

#!/bin/bash -

# @(#) s1       Demonstrate shell script parameter use.

echo "(Versions displayed with local utility \"version\")"
version >/dev/null 2>&1 && version =o $(_eat $0 $1)

echo
echo " Parameters beyond 9 explicit:"
echo " Parameter 10 is ${10}"
echo " Parameter 11 is ${11}"

echo
echo " Parameters with delayed evaluation using \"eval\":"
for ((j=1;j<=$#;j++))
do
  eval echo " Parameter $j is \${$j}"
done

exit 0

Producing:

% ./s1 a b c d e f g h i j k
(Versions displayed with local utility "version")
Linux 2.6.11-x1
GNU bash 2.05b.0

 Parameters beyond 9 explicit:
 Parameter 10 is j
 Parameter 11 is k

 Parameters with delayed evaluation using "eval":
Parameter 1 is a
Parameter 2 is b
Parameter 3 is c
Parameter 4 is d
Parameter 5 is e
Parameter 6 is f
Parameter 7 is g
Parameter 8 is h
Parameter 9 is i
Parameter 10 is j
Parameter 11 is k

However, I think shift is usually the most useful construct ... cheers, drl