How To Iterate Over FileNames With Spaces

This snippet will iterate over file names containing spaces in a directory.

1echo /my/**/dir | while IFS= read -r file
2do
3    echo "Doing some work with ${file}"
4    ls "${file}"
5done

This snippet will iterate over files that contain a string found by grep.

 1SCHEMA="newschema"
 2function listFiles {
 3    grep -lRi OLDSCHEMA \
 4       /dir1 \
 5       /dir2
 6}
 7
 8listFiles | while IFS= read -r file
 9do
10    echo "Replacing OLDSCHEMA with ${SCHEMA^^} in ${file}"
11    # ^ upercases the first letter, ^^ upper cases them app
12    sed-i "s/CORPDBA/${SCHEMA^^}/g" "${file}"
13done