I have a requirement to recursively loop through all the files of certain file types in a directory. The file types is an array variable containing the list of file types that we need to go through for processing. The array values are actually dynamically populated. For the sake of simplicity I am declaring a static array.
declare -a arr=("pdf" "doc" "txt")
I have the following code to recursively list all the files in the directory, but I am not able to figure out how include the array "arr" to only get back those file types that are included in the array.
find $i -type f -print0 | while read -d $'\0' file; do
echo $file;
#Process file
done
Please help me modify the code so that I could retrieve the specified file types only and not all files.