You need to use #!/bin/bash
as the first line in your script. If you don’t, or if you use #!/bin/sh
, the script will be run by the Bourne shell and its echo
doesn’t recognize the -e
option. In general, it is recommended that all new scripts use printf
instead of echo
if portability is important.
In Ubuntu, sh
is provided by a symlink to /bin/dash
.