tail Show the last lines of a file
Prints the end of a file, ten lines by default. It is the standard way to check the latest entries in a log, and it can keep running to show new lines as they are written.
Synopsis
tail [-F | -f | -r] [-qv] [-b number | -c number | -n number] [file ...]
Common options
| Option or form | What it does |
|---|---|
-n number | Show the last number lines instead of 10 |
-n +number | Start at line number and show everything from there to the end. tail -n +2 skips a header row |
-f | Follow the file: wait and print new lines as they are added. Stop with Ctrl-C |
-F | Like -f, but also notices if the file is renamed or replaced, as happens when logs rotate |
-c number | Count in bytes instead of lines |
-q | Do not print the ==> name <== header when given several files |
-r | Show lines in reverse order, last line first. Available on macOS and BSD, not in GNU tail |
Examples
tail app.log
tail -n 3 notes.txt
Beta again
error: disk full
delta
tail -n +2 data.csv
ana,red,7
bo,blue,3
cy,red,9
dee,blue,3
tail -n 20 app.log | grep ERROR
2026-01-01 ERROR failed to open
2026-01-02 ERROR timeout
tail -f /var/log/system.log
tail -F /var/log/nginx/access.log
Notes
- tail -f never exits on its own. Press Ctrl-C to stop it. This is why the example is not run automatically.
- Prefer -F over -f for logs that rotate. With -f, tail keeps reading the old file after it is renamed and shows nothing new.
- A plain number sets how far from the end to start. A leading plus sign changes the meaning to how far from the start: -n 5 is the last five lines, -n +5 is everything from line 5.
- -r exists on macOS and BSD but not on GNU/Linux. On Linux, use tac to reverse a file. The macOS man page also lists -b (512-byte blocks), which GNU tail does not have.
- With several files, tail prints a header with each file name. Use -q to hide it.
See also
Last reviewed 2026-10-07.