How to write a Bash script
Help 3 / 9
Your first script

Don't forget the shebang

Although the script ran successfully, it’s missing something really important: the so-called “shebang” line, which looks like this:

#!/bin/bash

This line should be the first line of any Bash script, so the computer knows that it is in fact a Bash script. We got away with not specifying it because the default is Bash on sandbox.bio, but on many systems, the default is often sh, a shell that predates bash. While many things that work in bash work in sh, many other things will break on you in unexpected ways.

Next, add that line at the very top of your script and save your changes (Cmd + S on Mac, Ctrl + S on Windows).

Loading...