Bash shift: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
(Created page with "=Internal= * bash =Overview= See positional parameters")
 
No edit summary
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
=External=
* http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_09_07.html
=Internal=
=Internal=


Line 5: Line 9:
=Overview=
=Overview=


See [[Bash_Environment_Variables#Positional_Parameters_.241.2C_.242.2C_...|positional parameters]]
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 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.