dimanche 18 novembre 2018

Bash: Difference between -eq and == [duplicate]

This question already has an answer here:

I am trying to understand difference between -eq and == in bash. I have tried with simple if but both are returning same results.

count=$(grep -c '^vboxadd:' /etc/passwd)

[test2@localhost ~]$ if [ $count -eq 1 ] ; then
>  echo "user account existed"
> else
> echo "NO"
> fi
user account existed

[test2@localhost ~]$ if [ $count == 1 ] ; then   echo "user account existed"; else echo "NO"; fi
user account existed
[test2@localhost ~]$

What is the preferable method should be used for cases as above ?

Aucun commentaire:

Enregistrer un commentaire