Shebang

From LQWiki
Jump to navigation Jump to search

shebang sometimes also called hashbang is the common name for the sequence of characters used at the start of a shell script, taking the form of a hash followed by an exclamation mark:

#!

The name derives from the "sh" sound at the end of "hash", plus "bang" which is a short name for the exclamation mark.

When used in a shell script the hash symbol typically denotes the beginning of a comment. However in the particular case of the shebang sequence occurring as the first two characters of a file, the running shell will treat the rest of first line as a path to the interpreter required to execute the script. For instance:

#!/usr/bin/perl

#!/usr/local/bin/bash

#!/bin/sh

#!/bin/awk -f

See also

Env(command) -- see the special trick section