Bash: Syntax error: redirection unexpected

Does your script reference /bin/bash or /bin/sh in its hash bang line? The default system shell in Ubuntu is dash, not bash, so if you have #!/bin/sh then your script will be using a different shell than you expect. Dash does not have the <<< redirection operator.

Make sure the shebang line is:

#!/bin/bash

or

#!/usr/bin/env bash

And run the script with:

$ ./script.sh

Do not run it with an explicit sh as that will ignore the shebang:

$ sh ./script.sh   # Don't do this!

Leave a Comment