Name
shift
Synopsis
shift [variable
]
If variable is given, shift the words
in a word list variable; e.g., assuming a wordlist variable named
offices
, offices[2]
becomes offices[1]
. With no argument, shift the
positional parameters (command-line arguments); i.e., $2
becomes $1
. shift is typically used in a while loop. See additional example under
while.
Example
while ($#argv) While there are arguments if (-f $argv[1]) wc -l $argv[1] else echo "$argv[1] is not a regular file" endif shift Get the next argument end
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.