The interpreter line

Most script files should start with a command interpreter line, which identifies the program or interpreter to be used to execute the rest of the script, as in:

#!/bin/bash
   
if this happens to be a bash shell script. Other possibilities might include /usr/bin/perl, /usr/bin/python, or /usr/bin/ruby.

If your script begins with such a line, it must be at the very top of the file, with no leading blank lines or whitespace.

Note

You don't have to start your script with such a line; it just makes it more convenient to execute, as you'll see shortly.

Tip

It's possible that you may inherit a script from someone else's system on which the actual interpreter was in a different location, so that the interpreter line contains the wrong full pathname, such as /usr/local/bin/ruby.

Not to worry. Rather than have to change the first line of each and every one of such scripts, anyone with root privilege can create a symbolic link to allow those scripts to run unchanged, as in:

# ln -s /usr/bin/ruby /usr/local/bin/ruby
    
At that point, /usr/local/bin/ruby is a valid value for the interpreter line.