shell常用基本命令之七 shift
2016-05-27 15:41
465 查看
1.shift的功能
1.所有的位置参数都左移1位,即$2变$1,$3变$22.$# 减1
2.举例
[root@nn shell]# cat shift_fun.sh #!/bin/bash echo "number of arguments is $#" echo "What you input is:" while [[ "$*" != "" ]] do echo "$1" shift done [root@nn shell]# ./shift_fun.sh hello world number of arguments is 2 What you input is: hello world [root@nn shell]#shift就是起到移位的作用
#!/bin/bash while [ "$#" -gt 0 ] do echo $* shift done 运行结果: [root@nn shell]# ./shift_fun1.sh 9 8 7 6 5 4 3 2 1 9 8 7 6 5 4 3 2 1 8 7 6 5 4 3 2 1 7 6 5 4 3 2 1 6 5 4 3 2 1 5 4 3 2 1 4 3 2 1 3 2 1 2 1 1
相关文章推荐
- android wifi 无线调试
- 运维入门
- 动态清空 nohup 输出文件
- install scrapy with pip and easy_install
- Linux Shell常用技巧
- Shell 脚本编程陷阱
- shell字符串操作详解
- Shell中删除某些文件外所有文件的3个方法
- Ruby中执行Linux shell命令的六种方法详解
- VB使用shell函数打开外部exe程序的实现方法
- Shell编程的一些知识集合
- Shell中的for和while循环详细总结
- 什么是Shell?Shell脚本基础知识详细介绍
- Shell脚本中引用、调用另一个脚本文件的2种方法
- Shell脚本解压rpm软件包
- Linux Shell 数组建立及使用技巧
- Shell脚本实现复制文件到多台服务器的代码分享
- Shell脚本实现批量替换文件内容
- Shell脚本实现的一个简易Web服务器例子分享
- linux Shell学习笔记第五天