shell--shell特殊参数

$(变量名)位置参数

注意
" "内是同一个位置
只引用一个位置的情况下 输入两个参数只会接受第一个
shell--shell特殊参数

多个位置参数

shell--shell特殊参数shell--shell特殊参数
注意:当位置参数数字大于9时,需要用大括号将数字括起来
shell--shell特殊参数

获取名称和路径

shell--shell特殊参数

shell--shell特殊参数

单独获取脚本文件的名称和路径

shell--shell特殊参数

通过$#获取脚本传参的个数

shell--shell特殊参数

利用set设置位置参数(同命令行脚本传参)

shell--shell特殊参数

$ *和[email protected]的区别

shell--shell特殊参数
shell--shell特殊参数shell--shell特殊参数shell--shell特殊参数

shift自动移动位置(遍历)

shift每次执行参数都-1
shell--shell特殊参数

$?获取上一个命令的退出状态

shell--shell特殊参数
shell--shell特殊参数shell--shell特殊参数