Bash shift: Difference between revisions

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


See [[Bash_Environment_Variables#Positional_Parameters_.241.2C_.242.2C_...|positional parameters]]
This command 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.
 
Say you have a command that takes 10 arguments, and N is 4, then $4 becomes $1, $5 becomes $2 and so on. $10 becomes $7 and the original $1, $2 and $3 are thrown away.
 
If N is zero or greater than $#, the positional parameters are not changed (the total number of arguments, see Section 7.2.1.2) and the command has no effect. If N is not present, it is assumed to be
 
Also see

Revision as of 20:23, 23 September 2017

External

Internal

Overview

This command 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.

Say you have a command that takes 10 arguments, and N is 4, then $4 becomes $1, $5 becomes $2 and so on. $10 becomes $7 and the original $1, $2 and $3 are thrown away.

If N is zero or greater than $#, the positional parameters are not changed (the total number of arguments, see Section 7.2.1.2) and the command has no effect. If N is not present, it is assumed to be

Also see