I'm trying to write a bash script to generate lists of files. I figured I'd simply call 'find' within a loop. Unfortunately it generated a "find: command not found" error when in the loop and I don't know why.
To keep things short, this cut-down version replicates the issue without bogging us down in irrelevant code.
#!/bin/bash
IFSprev=$IFS
IFS=$'|'
PATHS='openvpn|vms'
SOURCE='/mnt/store/'
#find "${SOURCE}vms" -type f
for PATH in ${PATHS}
do
echo -----------------------------------
find "${SOURCE}${PATH}" -type f
done
IFS=$IFSprev
While troubleshooting, I added the first 'find' command... with that added, it subsequently works within the loop. If I comment it out again, the 'find' in the loop reverts to throwing the error.
Given I'm gonna be redirecting the loop output to a file, I can live with the extra 'find' command or even just redirect to null. However, I'm an inquisitive kinda guy and I really want to find what the problem is.
Thanks for any input.
It's looking for
find
in$PATH
... which your script has destroyed.