bash if equals some file

34 Views Asked by At

I have a scripts that serves as a kill switch for another script. It compares the value of a file "kill.txt" of either a "0" or "1".

echo "KILL SWITCH: $(< /path/to/file/kill.txt)"
if [[ $(< /path/to/file/kill.txt) == 1 ]]; then
    echo "kill-switch engaged"
else
    echo "kill-switch NOT engaged"
fi

When "kill.txt" is saved to 1, the echo of the file outputs as 1 but the terminal outputs kill-switch NOT engaged when it should output kill-switch engaged. What am I doing wrong?

0

There are 0 best solutions below