GNU find
has a -print0
option to terminate filenames with null characters. However, this option is not available in POSIX find
.
In the GNU man page for find
, under the -print
flag, it says:
If you are piping the output of
find
into another program and there is the faintest possibility that the files which you are searching for might contain a newline, then you should seriously consider using the-print0
option instead of
This suggests to me that -print0
was introduced by GNU to specifically handle file paths with newline characters.
What alternative is available in POSIX for GNU's -print0
option, using either just POSIX find
or piping to a second POSIX command?
-print0
, then I assume you will also need to find POSIX alternatives to handling that output? Why not just use-exec
to process the pathnames directly? – Kusalananda Feb 05 '21 at 20:54-print0
does, but if-print0
was designed specifically for the purpose of piping the output toxargs -0
(which is also non-POSIX), then I guess there's no reason to try to find an alternative to-print0
in POSIX. – Shane Bishop Feb 05 '21 at 22:40-print0
to handle newline characters in paths (see my quote in my question). This (to me at least) makes it seem less likely that my question is a duplicate of How do I use find when the filename contains spaces?. Even if the answer to that question answers my question, the two questions IMO are different. – Shane Bishop Feb 06 '21 at 15:55