Home The Shebang: Magic Two Bytes That Launch Your Scripts

    The Shebang: Magic Two Bytes That Launch Your Scripts

    0
    10
    blank

    The shebang — those two characters (#!) at the top of every shell script — is one of Unix’s more understated pieces of elegance. When the kernel encounters a file starting with #!, it reads the rest of the line as the path to the interpreter and hands the script off accordingly. The name itself is a contraction of “sharp” (the musician’s word for #) and “bang” (hacker slang for !). Nobody quite agrees on who invented it; Dennis Ritchie and various Bell Labs alumni are candidates. What’s certain is that without it, every Unix script would need to be explicitly invoked with its interpreter, and shell scripting would be roughly 40% more tedious than it already is.