Follow a file as it grows

Read-only
What do risk levels mean?
Read-only
Inspects state without changing anything.
Low risk
Reversible with a routine follow-up command.
Medium risk
Changes state; undo path documented.
Destructive
Deletes or overwrites; confirmation required.

Streams new lines appended to a file in real time — the standard way to watch a log while reproducing a bug or monitoring a running job.

fileslogstailmonitor

Parameters

Path of the file to follow.

How many existing lines to show before following.

Commands

Print the last lines, then stream new lines as they are appended

tail -n 20 -f "<file>"

Verification

tail -n 1 "<file>"

The most recent line of the file, matching what the follow stream last showed.

Undo

Not undoable

This recipe only reads the file and changes nothing.

Pitfalls

  • If the file is rotated (renamed and recreated), plain -f keeps following the old file; use tail -F to reattach.
  • Press Ctrl+C to stop following; the command does not exit on its own.

Related