Session and utilities

The shift command

Shifts a script arguments left: $1 becomes the old $2.

Syntax

shift [n]

Copy-ready examples

$ printf 'echo inicio\nshift\necho fin\n' > s.shScript with shift
$ bash s.sh uno dosRun it with two arguments

You can try them in the browser terminal: it does not touch your computer.

Typical mistakes

  • After shift, the number of arguments ($#) drops.

Related commands

FAQ

Learn to actually use it

The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.

Start the free course