手机
当前位置:查字典教程网 >脚本专栏 >linuxshell >Bash Shell中Shift用法分享
Bash Shell中Shift用法分享
摘要:shift可以用来向左移动位置参数。Shell的名字$0第一个参数$1第二个参数$2第n个参数$n所有参数$@或$*参数个数$#shift默...

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

#----------------------------输出文字-结束----------------------------

【Bash Shell中Shift用法分享】相关文章:

shell命令行参数用法简介

bash 编程中循环语句用法

Shell脚本对比两个文本文件找出不同行的2个方法分享

Bash Shell脚本学习小结

使用Bash Shell获取文件名和目录名的简单方法

shell数组常用实例分享

shell查找当前目录下大于1M的文件的三种方法分享

Shell脚本实现的一个简易Web服务器例子分享

简介Linux中cp和mv搭配{,}在shell当中的用法

Shell脚本实现IP地址合法性判断

精品推荐
分类导航