January 2003
Intermediate to advanced
832 pages
32h 40m
English
shift
shift [variable]
If variable is given, shift the words in a
wordlist variable (i.e.,
name
[2] becomes
name
[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 an additional example under
while.
while ($#argv)While there are argumentsif (-f $argv[1])wc -l $argv[1]elseecho "$argv[1] is not a regular file"endifshiftGet the next argumentend