Forrest logo
back to the shift tool

shift:tldr:2ab64

shift: Move arguments by one place dropping the first argument.
$ shift
try on your machine

The "shift" command is a command used in computer programming languages or command-line interfaces to shift the positional parameters or arguments provided to a program or script. It is commonly used in shell scripting languages like Bash. When used in a shell script or a program, "shift" moves the position of the arguments one step to the left. This means that the value of the argument currently at position 2 will be assigned to position 1, the value at position 3 will be assigned to position 2, and so on. Each time "shift" is called, the positional parameters or arguments are reassigned new values, and the original value of the first argument is discarded. This allows the script or program to process the arguments one by one, as it moves through them using the "shift" command. Here's a simple example in Bash to demonstrate how "shift" works: ```bash

!/bin/bash echo "Processing arguments:" # Loop through all the arguments until there are none left

while [ $# -gt 0 ]; do echo "Argument: $1" shift done If you run this script with the command line: `./script.sh arg1 arg2 arg3`, it will output: Processing arguments: Argument: arg1 Argument: arg2 Argument: arg3

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the shift tool