shell除了局部变量,环境变量之外,还有特殊变量。如$0,$1,$2等等。
代码如下:
运行结果如下:
解释:
if [ -n "$1" ]是判断命令行第1个参数,在这里是aaa是不是为空。
$1,$2,$3......是命令行第1,2,3......个参数,超过10个,则需要用{},即${10},${11},${12}等等来表示。
*是通配符,$*就表示所有的$n。
shell除了局部变量,环境变量之外,还有特殊变量。如$0,$1,$2等等。
代码如下:
运行结果如下:
解释:
if [ -n "$1" ]是判断命令行第1个参数,在这里是aaa是不是为空。
$1,$2,$3......是命令行第1,2,3......个参数,超过10个,则需要用{},即${10},${11},${12}等等来表示。
*是通配符,$*就表示所有的$n。
了解Linux Shell中的一些特殊环境变量
shell脚本的使用---特殊变量及脚本的综合使用
前言shell中有一些有特殊意义的预定义变量,如位置参数等。特殊变量位置参数$n:执行一个脚本时,可能需要传入多个参数,n是几就
Shell特殊扩展变量 举例+说明+实战
本文主要讲述Linux中一些特殊变量的知识,旨在加强对这方面的知识的认知.
shell编程 特殊变量--位置变量
举报文章
请选择举报类型
补充说明
0/200
上传截图
格式支持JPEG/PNG/JPG,图片不超过1.9M