String comparison in bash. [[: not found

后端 未结 7 1398
故里飘歌
故里飘歌 2020-11-29 17:40

I am trying to compare strings in bash. I already found an answer on how to do it on stackoverflow. In script I am trying, I am using the code submitted by Adam in the menti

7条回答
  •  心在旅途
    2020-11-29 18:23

    I had this problem when installing Heroku Toolbelt

    This is how I solved the problem

    $ ls -l /bin/sh
    lrwxrwxrwx 1 root root 4 ago 15  2012 /bin/sh -> dash
    

    As you can see, /bin/sh is a link to "dash" (not bash), and [[ is bash syntactic sugarness. So I just replaced the link to /bin/bash. Careful using rm like this in your system!

    $ sudo rm /bin/sh
    $ sudo ln -s /bin/bash /bin/sh
    

提交回复
热议问题