shift - Shift positional parameters

Synopsis

shift [ n ]

Description

You can use shift to shift the positional parameters to the left by n. Positional parameter 1 is assigned the value of positional parameter (1+n), positional parameter 2 is assigned the value of positional parameter (2+n), and so forth. The special parameter # is updated with the new number of positional parameters.

Options

None.

Operands

The value of n must be an unsigned integer less than or equal to the special parameter #. If n is not specified, the default value is 1. If n is 0, there are no changes to the positional parameters.

Exit status

  • 0 when successful.
  • >0 when n is invalid.
Examples
Shift the positional parameters by two: shift 2