机器人 救救瓜
Toggle navigation
Home
SCM-tool
Linux
Jenkins
SVN
other
About Me
Archives
Tags
Shell if 用法
2019-01-29 14:49:09
1622
0
0
gua_l
Shell if ---------- 数值比较 ``` if [ $var -nq 0 ] if [ $var -eq 0 ] ``` ---------- 字符串比较 ``` if [ $var == $var1 ] if [ $var != $var1 ] ``` 字符串空 ``` if [ -z $var ] #(长度为0) ``` 字符串非空 ``` if [ -n $var ] #(长度为非0) if [ $var ] #(长度为非0) ``` --------- 变量不存在 ``` if [ ! -n $var ] ``` 文件是否存在 ``` if [ -e $var ] 不同文件存在的多种用法 -e filename 如果 filename存在,则为真 -d filename 如果 filename为目录,则为真 -f filename 如果 filename为常规文件,则为真 -L filename 如果 filename为符号链接,则为真 ``` 参数个数是否满足 ``` if [ $# -ne 5 ] ``` 多个条件取或取与时,逻辑结果要括两个方括号 ``` if [[ expression1 || expression1 ]]; then if [[ ${i} == CASADB_0_6 || ${i} == CASADB_0_7 || ${i} == FIS || ${i} == HeMS-V6_HA_3DB || ${i} == Mobility-5-Fixed-HA || ${i} == callHomeScripts ]]; then ```
Pre:
shell 里 sed的用法
Next:
Shell 拼接的用法
0
likes
1622
Weibo
Wechat
Tencent Weibo
QQ Zone
RenRen
Submit
Sign in
to leave a comment.
No Leanote account?
Sign up now.
0
comments
More...
Table of content
No Leanote account? Sign up now.