Fundamentals related to bash builtin command named “shift”

ABOUT shift

shift [n]

The  positional  parameters  from  n+1  ...  are renamed to $1 ....  Parameters represented by the
numbers $# down to $#-n+1 are unset.  n must be a non-negative number less than or equal to $#.  If n is
0, no parameters  are  changed. If  n  is not given, it is assumed to be 1.  If n is greater than $#, the
positional parameters are not changed.  The return status is greater than zero if n is greater than $# or
less than zero; otherwise 0.

[bash]
$cat posiwork
shift
echo $1
$./posiwork hello world
world
$./posiwork hello

$./posiwork hello world people
world
$emacs posiwork
$cat posiwork
shift 2
echo $1
$./posiwork hello world people
people
$

[/bash]
LINKS
https://askubuntu.com/questions/939620/what-does-mean-in-bash
https://www.computerhope.com/unix/bash/shift.htm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s