Debian Codegraph @

ex19.sh

raw symbols SCIP
1 #!/bin/bash
2 # shft.sh: Using 'shift' to step through all the positional parameters.
3
4 # Name this script something like shft.sh,
5 #+ and invoke it with some parameters.
6 #+ For example:
7 # sh shft.sh a b c def 83 barndoor
8
9 until [ -z "$1" ] # Until all parameters used up . . .
10 do
11 echo -n "$1 "
12 shift
13 done
14
15 echo # Extra linefeed.
16
17 # But, what happens to the "used-up" parameters?
18 echo "$2"
19 # Nothing echoes!
20 # When $2 shifts into $1 (and there is no $3 to shift into $2)
21 #+ then $2 remains empty.
22 # So, it is not a parameter *copy*, but a *move*.
23
24 exit
25
26 # See also the echo-params.sh script for a "shiftless"
27 #+ alternative method of stepping through the positional params.