UNIX in a Nutshell: System V Edition

UNIX in a Nutshell: System V EditionSearch this book
Previous: Reference: setenvChapter 5
The C Shell
Next: Reference: source
 

shift

shift [variable]

If variable is given, shift the words in a word list 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 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


Previous: Reference: setenvUNIX in a Nutshell: System V EditionNext: Reference: source
Reference: setenvBook IndexReference: source

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System