Most operating systems support the shebang syntax to run arbitrary scripts. We can use that approach to run stand-alone files with Scala code in it. This eliminates the needs to explicitly invoke the scala command and works seamlessly as long as Scala is installed on the system.
On Unix-like systems, set the shebang preamble in the script like this:
println("Hello " + args(0))
Make sure the file hello.sh has executable permission by typing chmod +x hello.sh. Then to run it, type the following command on the command line:
Buddy is the argument that is passed to the script. Here’s the output ...