Sample Header Ad - 728x90

How to check value inside a file using bash?

0 votes
2 answers
151 views
I'm trying to check if the value inside a file is "0".
COUNT_EXECUTION=$(< /tmp/count)

if [ "$COUNT_EXECUTION" == "0" ]; then
  echo "Try restart service."
else
  echo "There is execution in progress."
fi
File content is just a 0, but the test always falls into the else
Asked by Aderbal Nunes (137 rep)
Feb 20, 2025, 11:54 AM
Last activity: Feb 21, 2025, 06:11 AM