I have a file that contains a number. I want to read this number into a variable and then use it in an if statement. I am using the following command to populate the variable:
step='cat ./update_step'
The file, update_step has a single number stored in it. The number can be 0, 1, 2, 3, 4, or 5. For the sake of this example, the file contains the number "0".
if I check the variable as so:
$step
Then I get "0" as a return; which is expected.
But then if I try to use $step in an if statement like:
if [ $step -eq 0 ]
then
echo "this is an integer"
fi
I get a, "too many arguments" error.
If I check the variable with echo:
echo "$step"
Then the variable returns "cat ./update_step"
How do I read in the number that is stored in update_step as an integer (honestly it could even be a string at this point) so that I can use it with an if statement?