0

I would like to have a script that reads a number from a file, and if this number equals or higher a certain value, it will run another command, if not, script will just die, it would be something like this:

[root@firewall ~]# cat result.txt 
50
[root@firewall ~]# 
[root@firewall ~]# ./run.sh
result.txt is higher or equals 50. Running /sbin/reboot
[root@firewall ~]# 

Thanks for any help.

1
  • Can you show us what you have tried? Commented Nov 14, 2017 at 8:08

1 Answer 1

1
#!/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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.