shell if 如何取非
在Shell脚本中,可使用`!`操作符来取非。具体语法以下:
```shell
if ! condition; then
# code to be executed if the condition is false
else
# code to be executed if the condition is true
fi
```
在上述代码中,`!`操作符用于对`condition`进行取非操作。如果`condition`为true,则履行`else`后面的代码块;如果`condition`为false,则履行`if`后面的代码块。
TOP