I tried to move everything except a few items to a folder using a bash script with the following content. I tried these commands in the terminal first and got the expected results, but putting them inside a script produces the error mentioned below.
#! /bin/bash
shopt -s extglob
mv !(*.log | *.img) $1/build_files/ 2> /dev/null
ERROR:
build.sh: line 36: syntax error near unexpected token `('
build.sh: line 36: ` mv !(*.log|*.img) $1/build_files/ 2> /dev/null'
It'll be very helpful if someone could solve this. Thanks in advance.
shellcheck
to verify your script.