Where to start First steps track · 15 stages
Linux Labs

tee — output to a file and the screen

cheat sheet · GNU coreutils https://lab.dimsanych.ru/en/wiki/tee/

Cheat sheet

  • cmd | tee file show and write (truncates the file)
  • cmd | tee -a file append
  • echo x | sudo tee -a /etc/f >/dev/null write into a protected file
  • cmd 2>&1 | tee log including 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.

Loading…