0

As far as I can see, in most shell versions the expressions

if [ x = y ]

and

if [ x == y ]

have the same meaning.

Also, I saw, that there are versions, that don't allow ==, only =.

So is it true, that I can always use = instead of ==?

5gon12eder
  • 24,280
  • 5
  • 45
  • 92
  • 2
    You can always use a single `=` with the `test` (aka `[`) command. The double `==` does not work in all shells. – Jonathan Leffler Oct 29 '15 at 16:25
  • @fedorqui view [Elliott Frisch answer](http://stackoverflow.com/a/20449568/4767343) – Jose Ricardo Bustos M. Oct 29 '15 at 16:25
  • Since you say you've already discovered some differences yourself, it might help if you name them so people answering know where to start. – 5gon12eder Oct 29 '15 at 16:26
  • http://tldp.org/LDP/abs/html/comparison-ops.html – Dave Newton Oct 29 '15 at 16:26
  • @JoseRicardoBustosM. the fact that an answer points out the difference doesn't mean the question is duplicate. There, they ask about `==` and `-eq`, here `==` and `=`. Found an exact duplicate: [What is the difference between operator “=” and “==” in Bash?](http://stackoverflow.com/q/2600281/1983854) – fedorqui Oct 29 '15 at 16:27
  • 1
    By the way, for these kind of cases I use http://symbolhound.com/, where you can indicate, for example, a query like "bash = ==" which google doesn't recognise. – fedorqui Oct 29 '15 at 16:31
  • 2
    @fedorqui thanks, I did not know about [symbolhound.com](http://symbolhound.com/) .... – Jose Ricardo Bustos M. Oct 29 '15 at 16:38

0 Answers0