I'm trying to use find inside a loop to create a variable that contains a file matching the filename + desired string
Example:
file1.en.srt file1.mkv file1.pt.srt This is the relevant part of the code:
shopt -s nullglob shopt -s nocaseglob if [ -d "$1" ]; then for file in "${1%/}/"*mkv; do # Get filename to match against subs and audios filename="$(basename "$file" .mkv)" # Find matching subtitle file engsubs="$(find . -name "$filename*en.srt*" | sed -e 's,^\./,,')" # Find matching audio file engaudio="$(find . -iname "$filename*en.ac3" -o -iname "$filename*en.eac3" -o -iname "$filename*en.dts" | sed -e 's,^\./,,')" done fi It works if files don't contain brackets, but the find commands don't find anything for files whose names contain brackets. Why this is happening? I want to create a variable like $en that would contain file1.en.srt
$1?