Linux Bash脚本,该脚本将从文件中读取一个数字,并在该数字等于或大于X值时运行命令
我希望有一个脚本从文件中读取一个数字,如果这个数字等于或高于某个值,它将运行另一个命令,如果不是,脚本将消失,它将是这样的:Linux Bash脚本,该脚本将从文件中读取一个数字,并在该数字等于或大于X值时运行命令,linux,bash,unix,scripting,sh,Linux,Bash,Unix,Scripting,Sh,我希望有一个脚本从文件中读取一个数字,如果这个数字等于或高于某个值,它将运行另一个命令,如果不是,脚本将消失,它将是这样的: [root@firewall ~]# cat result.txt 50 [root@firewall ~]# [root@firewall ~]# ./run.sh result.txt is higher or equals 50. Running /sbin/reboot [root@firewall ~]# 谢谢你的帮助。你能告诉我们你试过什么吗? #!/
[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