Introduction

 

There may be times where it is convenient or required to use only a file path to run an executable script. This article covers how to specify in a file which program should be used to interpret it.

 

Procedure

 

Add the following line to the top of the script file, where INTERPRETER is replaced with the actual interpreter the file is written for. Note that "#!" must be the first 2 characters in the file.

#!/usr/bin/env INTERPRETER

 

To use Bash, you would add the following.

#!/usr/bin/env bash

 

To use Python 3, you would add the following.

#!/usr/bin/env python3

 

You can also specify a path to the binary directly. For example:

#!/usr/bin/bash
#!/usr/bin/python3