xargs — turn stdin into arguments
Some commands don't read stdin — rm, mv, git add. They want filenames as arguments. xargs bridges that gap: it reads stdin, splits on whitespace, and runs the next command with those tokens as arguments.
The flags you'll need
-n 1— one argument per command invocation.-I {}— placeholder;{}is replaced with each argument. Required when the arg isn't at the end.-0— read NUL-separated input. Pair withfind -print0for filenames containing spaces.-P 4— run up to 4 in parallel. Cheap parallelism.-r— don't run the command if stdin is empty (GNU; macOS BSD xargs already does this).
tee — split the stream
tee reads stdin and writes to both stdout and one or more files. Useful when you want to save output and watch it at the same time.
cmd | tee out.log— write to file, also display.cmd | tee -a out.log— append.cmd | sudo tee /etc/protected.conf— the canonical "write a file as root from a non-root pipeline."
Putting them together
find . -name '*.log' | xargs gzip — compress every log. find . -name '*.log' -print0 | xargs -0 -I {} -P 4 gzip {} — the same, parallel and space-safe. ./build.sh | tee build.log | grep -i error — capture full output and watch errors.