Back to lessons

Apple Terminal

Watch a Log or Build File Update

A developer or creator needs to monitor a changing log, export report, or build output file.

Command

tail -f ./app.log

What changed

Nothing changes. The command keeps the terminal attached and prints new lines as they appear.

Danger

safe

When to use it

Use for local logs, generated reports, build output, and simple text-based progress checks.

When not to use it

Do not use it for binary media files or huge one-time analysis. It follows appended text.

Undo or recovery

Press Ctrl-C to stop following the file.

Expected output

Existing tail lines followed by new lines as the file is appended.

demo script

Disposable terminal steps

  1. tail -n 1 project/logs/app.log
  2. printf '%s\n' 'request GET /health' >> project/logs/app.log; tail -n 2 project/logs/app.log

simulated output

What it looks like

disposable vessel
::fixture-ready::
$ tail -n 1 project/logs/app.log
exit
::exit-code::0
$ printf '%s\n' 'request GET /health' >> project/logs/app.log; tail -n 2 project/logs/app.log
exit
request GET /health
::exit-code::0

YouTube Short

Follow a log live.

tail dash f keeps watching a text file and prints new lines as they arrive. Stop it with Control C.

LinkedIn hook

Need to see whether a file is still changing? Let tail follow it live.

Question: What local file do you tail most often while building?

experiments

A/B tests to run

Metric: rewatch_rate

A: Show Ctrl-C prominently in the caption.

B: Mention Ctrl-C only in voiceover.