How to raise and take care of shell scripts: Shebang

What does this funny "#!" first script line mean?

If the first script line starts with the "Shebang" (this is the character sequence #!), the following path name shows the kernel the path to the interpreter, which should be used to run the script. If the line is missing, the script is executed using the default system's shell (mostly /bin/sh). That's why the shebang line is important not only for shell scripts, but for other interpreter languages (Perl, Tcl, Python, ...) too.

This is the reason to take care of this line: If you write a script expecting a particular shell you should add the path name of your required shell here - otherwise the wrong shell might be called:

  jan@jack:~> ls -l /bin/sh
  lrwxrwxrwx  1 root root 4 2004-04-28 22:19 /bin/sh -> bash

  #! /bin/sh
  # bash is called only if the link looks like in the listing above

  #! /bin/bash
  # bash is called

  #! /usr/bin/ksh
  # ksh is called