The problem here are NOT single quote ('
) and/or backtick (`
).
Rather, I needed to escape square brackets ([
and ]
) in order to prevent GNU find interpreting values of -name
(or -iname
) as a glob.
Super thanks to muru and Kamil Maciorowski for pointing me to the right direction!
Here's how I solved with this oneliner:
while IFS= read -r song; do
unsquare=$(printf '%s\n' "$song" | sed 's/\[/\\[/g;s/\]/\\]/g') &&
find /mnt/EXTHDD/unsorted -type f -name "$unsquare" ;
done < list.txt