转自:http://www.chengyongxu.com/blog/bash-shell%E4%B8%ADshift%E7%94%A8%E6%B3%95/

shift可以用来向左移动位置参数。
Shell的名字 $0
第一个参数 $1
第二个参数 $2
第n个参数 $n
所有参数 $@ 或 $*
参数个数 $#

shift默认是shift 1
以下边为例:

01 cat shift.sh
02 #----------------------------输出文字-开始----------------------------
03 #!/bin/bash
04 until [ -z "$1" ]  # Until all parameters used up
05 do
06   echo "$@ "
07   shift
08 done
09 #----------------------------输出文字-结束----------------------------
10  
11 sh shift.sh 1 2 3 4 5 6 7 8 9
12 #----------------------------输出文字-开始----------------------------
13 1 2 3 4 5 6 7 8 9
14 2 3 4 5 6 7 8 9
15 3 4 5 6 7 8 9
16 4 5 6 7 8 9
17 5 6 7 8 9
18 6 7 8 9
19 7 8 9
20 8 9
21 9
22 #----------------------------输出文字-结束----------------------------

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-09-25
  • 2022-12-23
  • 2022-01-04
  • 2022-02-24
  • 2021-07-16
猜你喜欢
  • 2022-12-23
  • 2021-12-17
  • 2022-12-23
  • 2022-12-23
  • 2021-07-03
相关资源
相似解决方案