You may notice that most shell and Perl script starts with the following line:
#!/bin/bash
OR
#!/usr/bin/perl
Let us find out why is it a good idea to use #!/usr/bin/env bash instead of #!/bin/bash as shebang?
The #! is called a shebang. It consists of a number sign and an exclamation point character (#!), followed by the full path to the interpreter such as /bin/bash. All scripts under Linux, *BSD, macOS, and Unix-like system execute using the interpreter specified on a first line. However, there is a small problem. BASH or Perl is not always in the same location (PATH) such as /bin/bash or /usr/bin/perl. If you want to make sure that script is portable across different UNIX like operating systems you need to use /usr/bin/env command as shebang.
#linux/unix