Should have explicit #!/bin/bash owing to use of [[ and ]]; Ubuntu is using dash as the default shell and trips on this as pointed out by GottfriedSp