Shebang

What is Shebang?

The term "shebang" refers to the "#!" located at the top of many script files that point to the associated program's path or executable.

For example, in a Perl script, the shebang line may look like the following:

#!/usr/bin/perl

This line instructs the operating system running the Perl script on where the executable for Perl and its associated files are located. In the above example, Perl is located under /usr/bin/perl.

The shebang line should occupy the very first (initial) line in a Perl script, and should be the only statement present on that line.

It may however also include a number of command "switches" after it. For example, the following shebang line would also instruct Perl to enable warnings:

#!/usr/bin/perl -w

The shebang line is commonly only required in Linux and Unix variants. When running Perl in some Microsoft Windows server environments, the initial shebang line may not be needed and can be omitted. However, it is best practice to always include it at the top of every Perl script.

Without a correct shebang line, a Perl script may fail to execute.


Related Terms


← Back to Glossary