美文网首页
shell中 shift 用法

shell中 shift 用法

作者: CarsonCao | 来源:发表于2019-02-18 23:20 被阅读0次

shift命令表示参数向左偏移,后面可跟数字(数字大小在参数个数范围内)
脚本:

#!/bin/sh

echo "first args:$1, args counts: $#"
shift 2
echo "first args:$1, args counts: $#"

执行结果:

$ sh shift.sh 1 2 3 4 5
first args:1, args counts: 5
first args:3, args counts: 3

相关文章

网友评论

      本文标题:shell中 shift 用法

      本文链接:https://www.haomeiwen.com/subject/bmjtyqtx.html