Jump to content

Shift

From Squishu Wiki

General

  • shift movs all params down by one such that $2 becomes $1, $3 becomes $2, etc.
  • As you use shift, $*, $@, and $# are modified in line with the new numbering
  • It's often used to scan thru params
  • Scan thru all positional params like this, after each is echoed it's discarded and it's on to the next param
while [ "$1" != ""]; do
    echo "$1"
    shift
done