Bash Shell中Shift用法
2012-10-12 13:49
162 查看
转自: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
以下边为例:
view
source
print?
shift可以用来向左移动位置参数。
Shell的名字 $0
第一个参数 $1
第二个参数 $2
第n个参数 $n
所有参数 $@ 或 $*
参数个数 $#
shift默认是shift 1
以下边为例:
view
source
print?
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 | #----------------------------输出文字-结束---------------------------- |
相关文章推荐
- Bash Shell中Shift用法分享
- Bash Shell中Shift用法分享
- Bash Shell中Shift用法
- Bash Shell中Shift用法分享
- jquery中push(),unshift(),splice() ,concat(),pop(),shift(),slice()等的用法(数组添加元素)
- js中push(),pop(),unshift(),shift()的用法小结
- pandas库中shift()、diff()等函数的用法
- Shell编程中Shift的用法
- 理解Bash shell中shift命令
- js中push(),pop(),unshift(),shift()的用法小结
- perl中shift与unshift的用法解析
- OD里SHIFT+F4条件断点用法篇
- perl 函数, 参数, @_, $_, $_[0], shift 的用法示例
- Bash Shell之date用法
- Shell编程中Shift的用法
- linux 中shift的用法介绍
- shift、unshift、 push、pop用法--JavaScript参考手册
- js中push(),pop(),unshift(),shift()的用法小结
- ps Ctrl+Alt+Shift+T 用法
- Shell编程中Shift的用法