What is the difference between “#!/usr/bin/env bash” and “#!/usr/bin/bash”?

后端 未结 5 693
谎友^
谎友^ 2020-11-28 00:05

In the header of a Bash script, what\'s the difference between those two statements:

  1. #!/usr/bin/env bash

  2. #!/usr/bin/bash<

5条回答
  •  臣服心动
    2020-11-28 00:41

    Instead of explicitly defining the path to the interpreter as in /usr/bin/bash/, by using the env command, the interpreter is searched for and launched from wherever it is first found. This has both upsides and downsides

提交回复
热议问题