如何组合以下两个命令:
find . -print0 | grep -z pattern | tr '\0' '\n'
find . -print0 | grep -z pattern | xargs -0 my_command
Run Code Online (Sandbox Code Playgroud)
进入单一管道?如果我不需要NUL分隔符,那么我可以这样做:
find . | grep pattern | tee /dev/tty | xargs my_command
Run Code Online (Sandbox Code Playgroud)
我想避免使用这样的临时文件:
find . -print0 | grep -z pattern > tempfile
cat tempfile | tr '\0' '\n'
cat tempfile | xargs -0 my_command
rm tempfile
Run Code Online (Sandbox Code Playgroud)
这个问题是对这些答案的后续跟进:
1)使用/ dev/tty显示中间管道结果:
https://unix.stackexchange.com/a/178754/8207082
2)使用NUL分隔的文件列表:
编辑使用my_command而不是command.
后续问题: