jeudi 2 juin 2016

The equal tilde operator not working in bash 4

In a server with bash version 3 I do this:

bash3$ e="tar xfz"; [[ "$e" =~ "^tar" ]] && echo 0 || echo 1
0

But when I execute the same command in bash version 4

bash4$ e="tar xfz"; [[ "$e" =~ "^tar" ]] && echo 0 || echo 1
1

I tried it in CentOS, Fedora and Ubuntu and got the same results. What is wrong?

Aucun commentaire:

Enregistrer un commentaire