TL;dr: How do I properly combine the -print0
option in find
with the -o
option to match multiple patterns? (The use case is to pass into xargs -0
)
Example:
find . -print0 -name "File*.dat" -o -name "Data*.txt"
find . -print0 -name "File*.dat" -o -print0 -name "Data*.txt"
Both of these return every file in the directory.
find . -name "File*.dat" -o -name "Data*.txt" -print0
This returns only files matching the second pattern (Data*.txt
).
How can I do this properly, and why does this happen?
find
with multiple-name
and-exec
executes only the last matches of-name
, doesn't matter if the action is-exec
or-print0
– ilkkachu Jan 02 '22 at 22:40