I already stumbled over #!/usr/bin/env bash on numerous occasions and never questioned it. Now, I'm wondering what the purpose of wrapping the shell interpreter in an env command, i.e. why not just write #!/bin/bash, #!/bin/sh or whatever?


1 Answer 1


I think this became popular because of python.

With this you can do

#!/usr/bin/env python3

for example and be quite sure env will find the right version and location for the executable.

Then this migrated to other shells because it seems like a good practice to always do even if you know where that particular shell is.

Not the answer you're looking for? Browse other questions tagged or ask your own question.