Positional parameters can be moved left with the shift command. For example, shift 3 means that the original $ $ is now $, the original $ $, and so on, the original $ $, $ $, $ $ no move. The shift command with no parameters is equal to shift 1.
Very useful Unix command: Shift. We know that for positional variables or command-line arguments, the number must be fixed, or when the Shell program does not know its number, you can assign all the arguments to the variable $*. If the user requires that the Shell does not know the number of position variables, can also be one by one of the parameters of one by one processing, that is, after $ $ $, in the back of $ $. The value of the variable before the shift command executes is not available after the shift command executes.
The test commands are as follows:
root@wl-ms-7673:/home/wl/Desktop/shell# cat-n test.sh
1 #shift command (x_shift.sh)
2 until [$#-eq 0]
3 The first parameter of Do 4 echo is: $# "
5 shift
6 done
root@wl-ms-7673:/home/wl/Desktop/ shell#
The output results are as follows:
root@wl-ms-7673:/home/wl/Desktop/shell# chmod u+x test.sh root@wl-ms-7673:/home/wl/
desktop/shell#./test.sh a b c d E F g