I wrote a Bash script, mscript.sh
for managing my music files, a part of it creates a list of such files.
all_exts=" -iname \"*.webm\" -o -iname \"*.mkv\" "
#all_exts=' -iname "*.webm" -o -iname "*.mp3" -o -iname "*.mp4" -o -iname "*.mkv" '
#The line below works fine
#find "${HOME}/pCloudDrive/SocialSciences/Arabic/al_aghani" -maxdepth 1 -type f -size +1M \( -iname "*.webm" -o -iname "*.mp3" -o -iname "*.mp4" -o -iname "*.mkv" \)|\
find "${HOME}/pCloudDrive/SocialSciences/Arabic/al_aghani" -maxdepth 1 -type f -size +1M \( "$all_exts" \)|\
awk -v FS="/" '{print $8}' > "${HOME}/pCloudDrive/SocialSciences/Arabic/al_aghani/list"
#it does not work with single quotes either
I get the following output,
find: paths must precede expression: -iname "*.webm" -o -iname "*.mkv" '
When I run the script without trying to interpolate all_exts
to my find command the script work fine. How might I correctly expand all_exts
?
P.S. This script is simple just for the sake of isolating the problem. I really need to interpolate all_exts
into the find command because I have many find commands doing this job in many different directories.