title: What is the meaning of !# (bang-pound) in a sh / Bash shell script?
body: <p>I want to understand how this Scala script works:</p>
  
  <pre><code>#!/usr/bin/env bash
  exec scala "$0" "$@"
  !#
  object HelloWorld {
      def main(args: Array[String]) {
          println("Hello, world! " + args.toList)
      }   
  }
  HelloWorld main args
  </code></pre>
  
  <p>On line 3, what is "!#" doing? Is the remainder of the file then fed to <a href="http://en.wikipedia.org/wiki/Standard_streams#Standard_input_.28stdin.29" rel="noreferrer">standard input</a> of the Scala program? Also, is '!#' documented anywhere?</p>
  
  <p>NB: The nearest thing I could find, although it is not directly relevant in any way is Stack Overflow question <em><a href="https://stackoverflow.com/questions/8967902">Why do you need to put #!/bin/bash at the beginning of a script file?</a></em> (about the beginning of a <a href="http://en.wikipedia.org/wiki/Bash_%28Unix_shell%29" rel="noreferrer">Bash</a> script).</p>