Skip to main content
Split to multiple lines for clarity
Source Link
terdon
  • 244.6k
  • 67
  • 464
  • 696

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

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

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
grammar
Source Link

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) interpreting them as a glob in Bash!.

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' "$video""$song" | sed 's/\[/\\[/g;s/\]/\\]/g') && find /mnt/EXTHDD/unsorted -type f -name "$unsquare" ; done < list.txt

The problem here are NOT single quote (') and/or backtick (`).

Rather, I needed to escape square brackets ([ and ]) in order to prevent -name (or -iname) interpreting them as a glob in Bash!

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' "$video" | sed 's/\[/\\[/g;s/\]/\\]/g') && find /mnt/EXTHDD/unsorted -type f -name "$unsquare" ; done < list.txt

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
Source Link

The problem here are NOT single quote (') and/or backtick (`).

Rather, I needed to escape square brackets ([ and ]) in order to prevent -name (or -iname) interpreting them as a glob in Bash!

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' "$video" | sed 's/\[/\\[/g;s/\]/\\]/g') && find /mnt/EXTHDD/unsorted -type f -name "$unsquare" ; done < list.txt