Bash shift: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
No edit summary
 
Line 9: Line 9:
=Overview=
=Overview=


This built-in command takes one number as argument and shifts the [[Bash_Environment_Variables#Positional_Parameters_.241.2C_.242.2C_...|positional parameters]] to the left by that number. The positional parameters from n + 1 to [[Bash_Environment_Variables#.24.23|$#]] are renamed to variable names from $1 to $# - n + 1. The first n positional parameters are thrown away.
This built-in command takes one number as argument and shifts the [[Bash_Built-In_Variables#Positional_Parameters_.241.2C_.242.2C_...|positional parameters]] to the left by that number. The positional parameters from n + 1 to [[Bash_Built-In_Variables#.24.23|$#]] are renamed to variable names from $1 to $# - n + 1. The first n positional parameters are thrown away.


If the number is not present, it is assumed to be 1.
If the number is not present, it is assumed to be 1.


If n is zero or greater than [[Bash_Environment_Variables#.24.23|$#]], the positional parameters are not changed and the command has no effect.
If n is zero or greater than [[Bash_Built-In_Variables#.24.23|$#]], the positional parameters are not changed and the command has no effect.

Latest revision as of 01:40, 24 September 2017

External

Internal

Overview

This built-in command takes one number as argument and shifts the positional parameters to the left by that number. The positional parameters from n + 1 to $# are renamed to variable names from $1 to $# - n + 1. The first n positional parameters are thrown away.

If the number is not present, it is assumed to be 1.

If n is zero or greater than $#, the positional parameters are not changed and the command has no effect.