shift
shell builtinLinux/Unix
The shift command is one of the most frequently used commands in Linux/Unix-like operating systems. shift Shift positional parameters in a shell script
Quick Reference
Command Name:
shift
Category:
shell builtin
Platform:
Linux/Unix
Basic Usage:
shift [options] [arguments]
Common Use Cases
Syntax
shift [n]
Options
Option | Description |
---|---|
n |
Optional numeric argument specifying the number of positions to shift (default is 1) |
Examples
How to Use These Examples
The examples below show common ways to use the shift
command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.
# Basic Examples Basic
# Remove the first positional parameter and shift all others down
shift
echo "$1" # Now displays what was previously in $2