Name

shift

Synopsis

    shift [n]

Shift positional arguments (e.g., $2 becomes $1). If n is given, shift to the left n places. Used in while loops to iterate through command-line arguments. In the Korn shell, n can be an integer expression.

Examples

shift $1+$6              Korn shell: use expression result as shift count

    shift $(($1 + $6))Same, portable to any POSIX shell

Get Unix in a Nutshell, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.