February 2001
Beginner to intermediate
448 pages
9h 2m
English
Official Description
Shifts positional parameters to the left ($2 becomes $1 and so on).
Syntax
shift [n]
Options
None
Oddities
Decrements $# (parameter count) after the shift.
There is no right shift—only a left shift.
Example
$ set den cheryl chris scott # Set up four positional parameters $ $ print $1 # $1 contains den den $ $ shift # Shift to the left by 1 $ $ print $1 # $1 now contains cheryl cheryl $ $ print $# # Parameter count is now 3 3 $ $ shift 2 # Shift by 2 $ $ print $# # Count is down to one 1 $ $ print $1 # $1 now contains scott scott $
Read now
Unlock full access