Posts Bash String Comparision with if
Post
Cancel

Bash String Comparision with if

Bash string comparision using “if”

”==” and “!=” only can be used in case of string comparision.

1
2
3
4
5
6
7
8
9
if [ "$STRING" == "abc" ];then
    echo "STRING is abc!"
fi 

or

if [ "$STRING" = "abc" ];then
    echo "STRING is abc!"
fi 

Appendix. References

This post is licensed under CC BY 4.0 by the author.