

免费资源网 – https://freexyz.cn/
shift可以用来向左移动位置参数。
Shell的名字 $0
第一个参数 $1
第二个参数 $2
第n个参数 $n
所有参数 $@ 或 $*
参数个数 $#shift默认是shift 1
以下边为例:代码如下:
cat shift.sh
#—————————-输出文字-开始—————————-
#!/bin/bash
until [ -z “$1” ] # Until all parameters used up
do
echo “$@ “
shift
done
#—————————-输出文字-结束—————————-sh shift.sh 1 2 3 4 5 6 7 8 9
#—————————-输出文字-开始—————————-
1 2 3 4 5 6 7 8 9
2 3 4 5 6 7 8 9
3 4 5 6 7 8 9
4 5 6 7 8 9
5 6 7 8 9
6 7 8 9
7 8 9
8 9
9
#—————————-输出文字-结束—————————-
免费资源网 – https://freexyz.cn/
© 版权声明
THE END
暂无评论内容