在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
后面的代码块。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读:shell if取非的方法是什么