Brace expansions can produce multiple instances of file names if there is an overlap in the matches.
A simple example:
mkdir testdir; cd testdir
touch abcd
for f in *{b,c}*; do something_to "$f"; done
# or more simply:
ls -l *{b,c}*
That is a very simplified example just for illustration. In this case, the single file abcd
would be processed (or listed) twice.
How can this list be best deduplicated?
- An associative array could be used.
- A carefully crafted glob/brace expansion could be used, but that's not robust.