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

When/why used the "shift" command

Status
Not open for further replies.

hpaille

Programmer
Apr 16, 2003
37
FR
Is there some best practices regarding the use of the shift command to read input parameters to a script (AIX) ?

I have seen some guidelines where they use the shift command from the 7th parameter. Is there any particular reasons for that ?
 
Hi

I think my code posted in thread822-1386700 is a good example.

Personally I almost always use [tt]while[/tt] and [tt]shift[/tt] instead of [tt]for[/tt]. But if your shell has a [tt]getopts[/tt] built-in function, is better to use that.

I do not understand your example with the 7th parameter, but so far looks pointless to use [tt]shift[/tt].

It could be absolutely necessary if the given shell can only refer directly to the first 9 parameters. But I do not think this is actually the case of any recent shell version.

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top