shell if 如何取非

2161
2023/8/13 13:19:47
栏目: 编程语言
开发者测试专用服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

在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 如何取非