shift — Shift positional parameters
Format
shift [expression]
tcsh shell: shift [variable]
Description
shift renames the positional parameters so that i+nth positional parameter becomes the ith positional parameter, where n is the value of the given arithmetic expression. If you omit expression, the default value is 1. The value of expression must be between zero and the number of positional parameters ($#), inclusive. The value of $# is updated.
shift is a special built-in shell command.
In the tcsh shell, without arguments, shift discards argv[1] and shifts the members of argv to the left. It is an error for argv not to be set or to have less than one word as value. With variable, shift performs the same function on variable. See tcsh — Invoke a C shell.
Examples
set a b c d
shift 2
echo $*
produce: c d
Localization
- LANG
- LC_ALL
- LC_MESSAGES
- NLSPATH
See Localization for more information.
Exit values
- 0
- Successful completion
- 1
- Failure because the expression had a negative value or was greater than the number of positional parameters.
Messages
- bad shift count expr
- You specified an expression that did not evaluate to a number in the range from 0 to the number of remaining positional parameters.
Portability
POSIX.2, X/Open Portability Guide, UNIX systems.
Allowing an expression, rather than just a number, is an extension found in the z/OS® UNIX shell.
Related information
set, sh, tcsh