Terdon's Example 3 from https://unix.stackexchange.com/a/612718/182280:
Select all files except those whose names end in
.sh
or.jkl
$ shopt -s extglob nullglob $ files=(!(*.sh|*.jkl)) $ echo "${files[@]}" file.abc file.ABC file.def file.ghi
The challenge is a space in the file causes failures in the script:
for f in ${files[*]} #https://unix.stackexchange.com/q/278502/182280
do
echo "Processing $f file... "
done
For example, the space in the file fi le1.jkl
"breaks" the file when processed by the script and returns:
processing `fi` file...
processing `le1.jkl` file...
What can be done to ensure that spaces do not "break" the file name?
Comments that serve to clarify the context / questions are appreciated.