Regarding tmp=$(find $Some_Dir -name "*.gz"):
- Always quote your shell variables, i.e.
"$Some_Dir", not just$Some_Dir, see https://mywiki.wooledge.org/Quotes. - Don't read file names into a scalar variable as it becomes much harder to deal with spaces in file names if you do, read them into an array.
so that should be:
readarray -d '' files < <(find "$Some_Dir" -type f -name '*.gz' -print0)
Now you can just loop on the files to do whatever you want, e.g. since you said I want to match the pattern starting with ZRT and ending with _somenumber:
re='ZRT.*_somenumber'
for file in "${files[@]}"; do
if [[ $file =~ $re ]]; then
do whatever you like
fi
done
Obviously you don't NEED the array of files in the first place, you could just doloop directly on the output of find:
re='ZRT.*_somenumber'
while IFS= read -r -d '' file; do
if [[ $file =~ $re ]]; then
do whatever you like
fi
done < <(find "$Some_Dir" -type f -name '*.gz' -print0)