I'm trying to run this script:
mkdir a
cd a
touch a1, a2, a_
ls ./a!(_)
echo -e '#!/bin/bash\nls ./a!(_)\n' >> run.sh
chmod a+x run.sh
./run.sh
The ls
line prints the output as expected (./a1, ./a2,
), but the script fails with:
./run.sh: line 2: syntax error near unexpected token `('
./run.sh: line 2: `ls ./a!(_)'
Is there any way to use parentheses in a bash script without using find
or for
?