Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bash: not absolute script #! interpreter?

Is it possible to say to a script to search for an interpreter not in an absolute location, but in his path?

For example, writing #!/usr/bin/php will fail if the user has php installed somewhere else.

Just writing #!php does not automatically work, of course, and I couldn't find anything about it, they just all treat this method as if it was "the way"® to do it.

So, is there a standard simple syntax to say "search for it anywhere in your path"?

like image 630
o0'. Avatar asked Sep 22 '10 10:09

o0'.


Video Answer


1 Answers

Try:

#!/usr/bin/env php
like image 98
Muhammad Alkarouri Avatar answered Sep 29 '22 21:09

Muhammad Alkarouri