The shift built-in removes some positional parameters or array values.
Syntax
-
shift [-A array] [count]
Description
The shift built-in removes the first count positional parameters or array values, where count is specified by the operand.
Options
-
-A array
-
--array=array
-
Remove first count values of array instead of positional parameters.
Operands
- count
-
The number of positional parameters or array values to be removed.
It is an error if the actual number of positional parameters or array values is less than count. If omitted, the default value is one. If negative, the last -count positional parameters or array values are removed instead of the first ones.
Exit status
The exit status of the shift built-in is zero unless there is any error.
Notes
The shift built-in is a special built-in.
The number of positional parameters can be obtained with the
#
special parameter.
The number of array values can be obtained with ${array[#]}
.
The POSIX standard defines no options for the shift built-in; the built-in accepts no options in the POSIXly-correct mode.
Negative operands are not allowed in the POSIXly-correct mode.