tee
tee
allows you to copy STDOUT to a file or another command. It effectively lets you do two things with one set of text.
Usage
My most common usage is printing out the thing that will be used next in a command.
# This sends the branches found to STDOUT and to a file
git branch | grep 'query' | tee > "/tmp/found_branches"
# This sends the first found branch to STDOUT and then does a checkout
git branch | grep 'query' | tee >(xargs -n 1 -I {} sh -c 'git checkout "{}"')
References
Last modified: 202503161545