In Linux, SheBang (= #!) denotes executable script file

How to do things, solutions, recipes, tutorials
Post Reply
Message
Author
kethd
Posts: 451
Joined: Thu 20 Oct 2005, 12:54
Location: Boston MA USA

In Linux, SheBang (= #!) denotes executable script file

#1 Post by kethd »

SheBang = #!
(also called hash-bang)
special code at beginning of executable script text files

ShellScripts

See also: FileTypeAssociation
ash
bash

http://www.halley.cc/ed/linux/newcomer/shebang.html?
The Whole Shebang, or What's in a Script
A shell script is merely a list of commands to be executed in the proper order by a shell environment like bash. A shell script can do anything that you could type manually. Conversely, you could type anything that a shell script contained, to do the same tasks manually.

There are many shell script interpreters, and some that are not even intended for use as an interactive command prompting space for users to type their commands. For example, Perl scripts may start with a shebang line similar to #!/usr/local/bin/perl. They're still interpreted by that process and any code within is executed on behalf of the user who invoked the command.

Also, note that the filename has nothing to do with the type of shell required for running the script. The script could have been called sample, or sample.pl or even kernel.exe. In Unix and Linux, it is the contents (such as its shebang), and not the name, which determines how the system will go about executing or opening the file. Many of the commands you run in Linux are just shell scripts that have no filename extensions.

Some helpful manual pages on your Linux system may be (help source), (man bash), (man chmod), and (man perl).

Some helpful google searches may be linux shell commands scripts, linux shebang notation, linux bash PATH variable, linux file mode permissions, and common scripting languages.

User avatar
Flash
Official Dog Handler
Posts: 13071
Joined: Wed 04 May 2005, 16:04
Location: Arizona USA

#2 Post by Flash »

Would whoever moved this to the Howto section please explain why? It doesn't seem to me that it belongs here.

Post Reply