Maybe I'm being really silly here but I can't seem to figure this out:
#!/usr/bin/env bash
...
DELTAS=($(ls -p /foo/bar/ | grep -P '^\d+[^\.]+\.sh$'))
...
If I run this interactively it's fine, and echo $DELTAS returns:
1-foo.sh
2-bar.sh
However, when this is run inside a bash script, I receive Syntax error: "(" unexpected; any ideas?
#!line. Copy and paste it, don't re-type it. The error message implies that your script is being run usingshrather thanbash. In a comment you say the script starts with#!/usr/bin/env bash(#!/bin/bashwould be simpler). Are you certain you have the syntax of the#!line right?