I'm trying to write a cross-platform command line that will find all local files on a file system.
My intention is to use the find
command, using only POSIX parameters. Is there a way to skip files on remote filesystems, while restricted to only POSIX commands, and no programming?
My current command line is
find -type f -print
but that obviously lists every regular file, not just local ones.
I am aware of the -local
flag, but as far as I can tell, it's not POSIX or otherwise part of a cross-platform standard. locate
doesn't appear to be cross-platform either. I don't think the -xdev
flag is what I'm looking for, either, as I want to search across all locally mounted file systems - if /
and /home
are both local, and I run find / -xdev -print
, find
should skip /home
(unless I'm misunderstanding stuff).
For what it's worth, the following URLs have been useful resources...
-xdev
is correct. Have you looked at (ab-)using find's-fstype
option at all?-exec
to run any command as a test (and proceed with thefind
primaries or not, based on its exit status). If you have a POSIX command which will return 0 if and only if it's run on a local file, you could make use of that.