brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: tee -a writes terminal output to a log and still shows it

Terminal
~/tips/tip-terminal-tee-append-log

./backup.sh 2>&1 | tee -a backup.log

Shows output on screen and appends the same output to a log file.

I want to watch a long job and keep a copy of what it said.

./backup.sh 2>&1 | tee -a backup.log

tee copies standard input to the screen and to the file. -a appends, otherwise the file is overwritten. 2>&1 adds error messages to the stream. The exit status of the pipeline is that of tee, so a failed script looks successful unless you use set -o pipefail or check ${PIPESTATUS[0]} in bash. Some programs change their output when they are not writing to a terminal.

Further reading: tee manual page

More Terminal tips ioreg -rn AppleSmartBattery | grep CycleCount Terminal can save your windows and tabs as a window group Export a Terminal profile to a .terminal file and import it on another Mac mc hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000039,"HIDKeyboardModifierMappingDst":0x700000029}]}' All Terminal tips (116) All topics

Link