x

SHIFT command in Unix

PREV     NEXT

SHIFT command in Unix:


  • The shift command in UNIX is used to move the command line arguments to one position left. The first argument is lost when you use the shift command.
  • Shifting command line arguments is useful when you perform a similar action to all arguments one-by-one, without changing the variable name. The shift command throws away the left-most variable (argument number 1) and reassigns values to the remaining variables.
  • The value in $2 moves to $1, the value in $3 moves to $2, and so on.

Example for SHIFT command in Unix:

Execution Results:



Like it? Please Spread the word!