shift

shift KornShell positional parameters 

KornShell Built-in


SYNOPSIS

shift [expression]


DESCRIPTION

shift renames the KornShell 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.


EXAMPLE

The commands:

set a b c d
shift 2
echo $*

produce:

c d

DIAGNOSTICS

Possible exit status values are:

0 

Successful completion.

1 

Failure because the expression had a negative value or was greater than the number of positional parameters.

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 4.0. All UNIX systems. Windows 10. Windows Server 2016. Windows Server 2019. Windows 11. Windows Server 2022. Windows Server 2025.

Allowing an expression, rather than just a number, is an extension found in the KornShell.


NOTE

This is a special built-in command of the MKS KornShell and should not be confused with the shift command internal to cmd.exe.


AVAILABILITY

PTC MKS Toolkit for Power Users
PTC MKS Toolkit for System Administrators
PTC MKS Toolkit for Developers
PTC MKS Toolkit for Interoperability
PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition
PTC Windchill Requirements and Validation


SEE ALSO

Commands:
set, sh


PTC MKS Toolkit 10.5 Documentation Build 40.