[英]Bash script that will read a number from file and run command if number equals or is higher than X value
我希望有一个脚本从文件中读取一个数字,如果该数字等于或大于某个特定值,它将运行另一个命令,否则,脚本将死,这将是这样的:
[root@firewall ~]# cat result.txt
50
[root@firewall ~]#
[root@firewall ~]# ./run.sh
result.txt is higher or equals 50. Running /sbin/reboot
[root@firewall ~]#
谢谢你的帮助。
#!/bin/bash
THRESHOLD=50
VALUE=$(cat result.txt)
# -eq -> equals
# -gt -> greater than
# -ge -> greater than or equal (you are looking for this one)
if [ $VALUE -ge $THRESHOLD ]
then
# Your action
fi
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.