0

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?

marked as duplicate by sebasth, Ipor Sircer, Thomas, Thomas Dickey, Community Oct 7 '18 at 10:37

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

0

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.