Bash "file.sh" error in if extracting cat output to a variable and comparing it in if

0

When extracting the variable, everything is correct, but it does not compare it to me, any help?

camMode= sudo cat data.txt;

echo "$camMode";

if [ "$camMode" == "True" ]; then

        echo Mode is true
fi


if [ "$camMode" == "False" ]; then
        echo Mode is false
fi
    
asked by Teodor Din 27.12.2018 в 13:40
source

1 answer

0

It's simple, you just have to change

  

camMode = sudo cat data.txt;

for

  

camMode = $ (< data.txt);

Apparently the output of the console can not be determined as a string, but when reading the document in this way, if it allows it.

    
answered by 27.12.2018 в 14:22