Tail : Prints last 10 lines of log file

NAME
tail – display the last part of a file

DESCRIPTION
The tail utility displays the contents of file or, by default, its standard input, to the standard output.

The display begins at a byte, line or 512-byte block location in the input. Numbers having a leading plus (‘+’) sign are relative to the beginning of the input, for example, “-c +2” starts the display at the second byte of the input. Numbers having a leading minus (‘-’) sign or no explicit sign are relative to the end of the input, for example, “-n 2” displays the last two lines of the input. The default starting location is “-n 10”, or the last 10 lines of the input.

Synopsis
tail [options] [file]

Prints the last 10 lines of a system log file:
tail -f /private/var/log/system.log

Prints the last 10 lines of a install log file:
tail -f /private/var/log/install.log

Extract lines 40-50 from a file, first using head to get the first 50 lines then tail to get the last 10:
head -50 file.txt | tail -10

Show the last 20 lines containing instances of .wow
grep '\.wow' file | tail -20

Copy install log to desktop
cp /var/log/install.log ~/Desktop

Link:
https://ss64.com/osx/tail.html

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *