Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Bash if a variable is equal to true

I want to check if the variable is equal to the true keyword and if it is then do something accordingly but it is behaving in an undefined way. don’t get what I want its a simple question but thank you : >

STRICT=$false

if [ "$STRICT" == $true ] # i am not sure about this line what should i do
  then  
  FS="${FS} hey"
fi

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Just use strings true and false, not variables.

STRICT=false

if [ "$STRICT" = true ]
then  
  FS="${FS} hey"
fi

And the standard string comparison operator is =. == is a bash extension.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading