9.3.24 shift command (shifts the run-time parameters)
Syntax
shift [n]
Description
This command shifts all the run-time parameters so that a specified subsequent parameter becomes set in the first position.
Argument
- n
Specifies the number of places by which the run-time parameters are to be shifted. When this argument is specified, the run-time parameters are shifted by the specified number of places. When this argument is omitted, 1 is assumed (the second parameter becomes the first parameter, and so on). If you specify 0, the run-time parameters are not shifted. If you specify a negative or non-numeric value, the command terminates with an error. If you specify a value greater than the number of run-time parameters, the command terminates with an error.
Return codes
Return code |
Meaning |
---|---|
0 |
Normal termination |
1 |
Error termination |
Notes
If you specify 0 for the argument, the run-time parameters are not shifted. If you intend to use the shift command to iterate through the run-time parameters in a for statement, while statement, or other looping control structure, be sure not to specify 0 for the argument.
If the command syntax of this special built-in command is invalid, it exits the shell that is executing the command.
Example
Shift the run-time parameters by 2 places.
shift 2