The first line

The first line of a script can identify the interpreter to use.

The first line of many—if not most—shell scripts is in this form:

#! interpreter [arg]

For example, a Korn shell script likely starts with:

#! /bin/sh

The line starts with a #, which indicates a comment, so the line is ignored by the shell processing this script. The initial two characters, #!, aren't important to the shell, but the loader code in procnto recognizes them as an instruction to load the specified interpreter and pass it:

  1. the path to the interpreter
  2. the optional argument specified on the first line of the script
  3. the path to the script
  4. any arguments you pass to the script

For example, if your script is called my_script, and you invoke it as:

./my_script my_arg1 my_arg2 ...

then procnto loads:

interpreter [arg] ./my_script my_arg1 my_arg2 ...

Some interpreters adjust the list of arguments:

For example, let's look at some simple scripts that echo their own arguments.