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

后端 未结 5 655
谎友^
谎友^ 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:57

    Using #!/usr/bin/env NAME makes the shell search for the first match of NAME in the $PATH environment variable. It can be useful if you aren't aware of the absolute path or don't want to search for it.

提交回复
热议问题