Using tee To Split CLI Output
Published on
Store the output of some CLI operation and see the results in real-time
tail -f /var/log/postgresql/postgresql-13-main.log | grep deadlock | tee ~/postgres-deadlocks.log
This command will stream the logs written to /var/log/postgresql/postgresql-13-main.log
, filter for lines containing deadlock
, writes those lines to ~/postgres-deadlocks.log
, and finally display that output to the terminal.
Use tee --append
to append to the specified file instead of the default of overwriting it.