29 lines
723 B
Bash
29 lines
723 B
Bash
#!/bin/bash
|
|
if [ -z "$1" ]; then
|
|
echo -e 'Usage:\n\tfind_ext.sh <str extensions whitelist> <str extensions blacklist>\n\tfind_ext.sh "jpg mp3 png" ["doc pdf svg"]'
|
|
exit 1
|
|
else
|
|
# start the whitelist group
|
|
whitelist_find_str='\('
|
|
|
|
# break whitelist str into array
|
|
IFS=' ' read -r -a whitelist <<< "$1"
|
|
|
|
# loop through array of whitelisted exts
|
|
for ext in "${whitelist[@]}"; do
|
|
whitelist_find_str+=" -iname \" *.${ext}\" "
|
|
done
|
|
|
|
# finish the whitelist group
|
|
whitelist_find_str+='/)'
|
|
|
|
echo "$whitelist_find_str";
|
|
|
|
# make find command
|
|
# find_cmd="find . "
|
|
fi
|
|
|
|
if [ ! -z "$2" ]; then
|
|
# break blacklist str into array
|
|
IFS=' ' read -r -a blacklist <<< "$2"
|
|
fi |