I'm having some troubles getting a shell script to work. I'm trying to dynamically generate the find command based on user input and I'm running into the problem that my variables in the find command are getting enclosed in single quotes like already described here.
So if i echo my variable they'll show up like -iname "*.flv"
but once they are in the find command they are -iname "*.flv"
with single quotes and the find command isn't executed.
I've tried to implement the answers given in that other SO thread but I can't figure it out.
Any idea what's wrong there?
Thanks!
if [[ ! "$medium" == "" ]]
then
needles=$needles' -iname "'*$medium*'"'
fi
echo $needles
#-iname "*.flv"
echo $path
#/Users/user/Movies/
find "$path" $needles -type f -exec basename {} \; | gshuf -n 1
# + find '/Users/user/Movies' -iname '"*dvd*"' -type f -exec basename '{}' ';'