tee — output to a file and the screen
cheat sheet · GNU coreutils https://lab.dimsanych.ru/en/wiki/tee/Cheat sheet
-
cmd | tee fileshow and write (truncates the file) -
cmd | tee -a fileappend -
echo x | sudo tee -a /etc/f >/dev/nullwrite into a protected file -
cmd 2>&1 | tee logincluding stderr
Options
Without -a, tee truncates the file to zero before writing — for logs
and configs that get appended to rather than recreated, -a is always
needed. -i makes tee ignore SIGINT (Ctrl+C), so an interrupt
doesn't stop the write before the command itself finishes in the
pipeline.