How can I combine the following two commands:
find . -print0 | grep -z pattern | tr '\0' '\n'
find . -print0 | grep -z pattern | xargs -0 my_command
into a single pipeline? If I don't need NUL separators then I can do:
find . | grep pattern | tee /dev/tty | xargs my_command
I want to avoid using a temporary file like this:
find . -print0 | grep -z pattern > tempfile
cat tempfile | tr '\0' '\n'
cat tempfile | xargs -0 my_command
rm tempfile
This question is a follow-up to these answers:
1) Using /dev/tty to display intermediate pipeline results:
https://unix.stackexchange.com/a/178754/8207082
2) Using a NUL-separated list of files:
https://stackoverflow.com/a/143172/8207082
Edited to use my_command
instead of command
.
Follow-up question: