#!/bin/bash
while [ $# -ne 0 ]
do
#参数个数,,,始终输出第一位参数
echo $#,$1
# 参数向左移动,最左边丢掉
shift
done
~
运行结果如下
[root@iZbp15y9kxqiob8bepun7nZ ~]# bash shift_test.sh a b c
3,a
2,b
1,c
#!/bin/bash
while [ $# -ne 0 ]
do
#参数个数,,,始终输出第一位参数
echo $#,$1
# 参数向左移动,最左边丢掉
shift
done
~
运行结果如下
[root@iZbp15y9kxqiob8bepun7nZ ~]# bash shift_test.sh a b c
3,a
2,b
1,c