I have spent days on this Rubik's cube. Anything I do to fix one problem breaks another.
I am on POSIX compliant MacOS X 10.5 thru 10.14. I am calling this from a Perl script in a context of
system ("find blah blah > FILENAME");
I need Unix 'find' to do all these things at once.
- start at a volume root e.g.
- do not cross file systems
- print files only, not directories or symlinks
- do not even descend into multiple directories like
net dev system. (I.e. do not explore /Volumes/foo/dev/ but do explore /Volumes/foo/Users/Jim/dev/github/twonky/)
- the start point may contain spaces
Right now I am doing the following: (broken into several lines for readability; it's actually one long line)
Find -x '/Volumes/foo/' -path '/Volumes/foo//dev/*' -prune -path '/Volumes/foo//net/*' -prune -path '/Volumes/foo//system/*' -prune -o -type f -print
The reason for the double / is find’s printout includes the // because the starting point ends in a /. The Prune paths must agree, or they won't match. Why does the starting point end in /? Because if it doesn't, find fails on any starting point with a space in the name, like "My HD". Tried that.
Right now, find is only excludes the first directory in the list. The rest, it just ignores. I am currently testing on OS X 10.5 but I need something that works everywhere.
Is multiple prunes + files only + spaces in filenames a bridge too far? Am I just asking too much of find?