O'Reilly logo

Linux in a Nutshell, Fourth Edition by Aaron Weber, Stephen Figgins, Ellen Siever

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

shift

Synopsis

                  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 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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required