Search This Blog

Wednesday, 22 April 2020

(17) Dale Gulledge's answer to What is a shebang in Linux? - Quora

linux shebang 

https://www.quora.com/What-is-a-shebang-in-Linux/answer/Dale-Gulledge

A shebang refers to the first two characters in a script, #!. When those appear at the beginning of the first line of a text file that has had it's executable bit set, and are followed by a valid command interpreter, Linux passes the script to it. Now just to be clear, the only reason I say a "valid command interpreter" is that that is the intent. You can get away with using the path to any executable program. So what happens when I start a script with

  1. #!/usr/bin/perl -w

it will run /usr/bin/perl with the flag -w, followed by the name of the file. So if the file was foo.pl, the command line that will actually be executed will be

  1. /usr/bin/perl -w foo.pl

It will work with the interpreters for pretty much any interpreted language.


No comments:

Post a Comment