bash变量
准备工作
bash 中的变量
echo $PS1
echo $IFS
特殊变量
$$ 当前bash的进程号
$_ 最后一个参数
$! 前一个进程号
set -- "this is" a beautiful day
echo $#
echo $*
echo $@
]# today='"this is" a beautiful day'
]# echo ${today}
"this is" a beautiful day
]# echo ${#today}
25
]# echo ${today:2}
his is" a beautiful day
]# echo ${today:2:2}
hi
]# echo ${today#\"this}
is" a beautiful day
]# echo ${today%day}
"this is" a beautiful
# 如果var 没有定义或var="" 则返回 string
]# result=${var:-string}
#var变量未赋值则 $var=sting
]# a=${var:=string}
[root@master prometheus]# stat -c %A `which curl`
-rwxr-xr-x
[root@master prometheus]# stat -c %a `which curl`
755