On linux, this was the fastest for me. Use (bash) globbing and printf as follows:
printf "%s\n" directoryfile printf "%s\x00" directoryfilename-with-special-characters | xargs -0 command
It seems to be much faster than
find directory -name file
or
ls -1R directory | grep file
or even, surprisingly,
ls directoryfile
It was a local file system: x86_64 system, ext4 file system on SSD, in the directory structure more than 600,000 directories with several files in them.
source share