A shebang 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 UNIX and Linux execute using the interpreter specified on a first line.
Bash, Perl, PHP, Shell interpreters are not always in the same location such as /bin/bash
or /usr/bin/perl
. If you want to make sure that script is portable across different UNIX like operating system you need to use /usr/bin/env
command.
env
command allows to run a program in a modified environment.
# Find line
#!/bin/bash
# Replace with
#!/usr/bin/env bash
#!/usr/bin/env php
#!/usr/bin/env perl