Shell script 中 if 语句的条件判断字符的含义
为了捣鼓 FreeNAS 开始看一些系统自带的 shell script,但是老本都亏空了,只能大概看懂,基本的 if 语句中判断字符都忘记了。搜了一下,记录在这里,方便以后查询。短小精悍的在这里 http://lowfatlinux.com/linux-script-logic.html 最全面的在这里http://www.freeos.com/guides/lsst/C
·
为了捣鼓 FreeNAS 开始看一些系统自带的 shell script,但是老本都亏空了,只能大概看懂,基本的 if 语句中判断字符都忘记了。搜了一下,记录在这里,方便以后查询。
短小精悍的在这里 http://lowfatlinux.com/linux-script-logic.html 最全面的在这里http://www.freeos.com/guides/lsst/
Comparisons:
-eq | equal to |
-ne | not equal to |
-lt | less than |
-le | less than or equal to |
-gt | greater than |
-ge | greater than or equal to |
File Operations:
-s | file exists and is not empty |
-f | file exists and is not a directory |
-d | directory exists |
-x | file is executable |
-w | file is writable |
-r | file is readable |
-n 变量是否有值
-z 变量是否为空
两个条件的联合判断
-a and
-o or
! not
更多推荐
已为社区贡献1条内容
所有评论(0)