I tried the following and it didn't work one bit.
image=.jpg,.png,.gif find . -type f -iname "*$image"
Why? Does find not expand variables?
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
I don't think find supports multiple extensions in that way. As per this post by Alvin Alexander, you can do it like this:
find . -type f \( -name "*.jpg" -o -name "*.png" -o -name "*.gif" \)
With using the environment variable (assuming bash is the shell):
export image="-name *.jpg -o -name *.png -o -name *.gif" find . -type f \( $image \)