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

Positional Parameters

Status
Not open for further replies.

RJSHA1

Programmer
Apr 12, 2001
66
GB
Hi there,
In shell programming is there a limit to the number of positional parameters that you can pass as parameters
to a shell script


Thanks

bob....

 
Yes, there's a limit -- two kinds of limit actually. One that's easy to work around and one that's large enough to hardly every cause you a problem.

First one.

In a shell script you can only refer to $1 thru $9, this is a pain only until you realise you can call "shift" and everything shifts down one, so that the $10 you couldn't get at is now $9.

Second one.

There's a hard limit to the number of parameters that get passed to any program. This will probably differ from shell to shell but for ksh (if I remember correctly) it's 255.

So -- you can get up to 255 parameters into your shell script but you have to call "shift" to get at any thing past the nineth one. Mike
________________________________________________________________

"Experience is the comb that Nature gives us, after we are bald."

Is that a haiku?
I never could get the hang
of writing those things.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top