Shift

Last updated

What is Shift?

The shift command in shell scripting renames the command-line arguments. Specifically, it moves each argument one position to the left. The value of $2 becomes $1, the value of $3 becomes $2, and so on. The original value of $1 is lost. This is particularly useful when you need to process a variable number of arguments passed to a script.

Free resources to learn Shift

More in stage 19: Script Arguments

Shift: common questions

Can I learn Shift in Hindi?

This lesson is written in English. Once you sign in, open it in the interactive course and ask the AI tutor to explain Shift in Hindi or Hinglish. The tutor answers from this lesson’s own text, so it stays on the syllabus, and it runs on your own Google, OpenAI or Anthropic key.

Is this Shift tutorial for beginners?

It is lesson 96 of 166 in the free Shell / Bash roadmap, in stage 19, Script Arguments. If you are new to Shell / Bash, start from stage 1 and come back here in order; if you already know the earlier stages, this lesson stands on its own.

Still confused? Ask me