Text processing

Linux tail command

Show the last lines of a file. Use -f to follow new lines as they arrive.

Availability: Common Linux commands; shell built-ins and external implementations may differ by distribution.中文

Syntax

tail [OPTION]... [FILE]...

Examples

Show the last 50 lines of a log.

tail -n 50 app.log

Follow a log through rotation or replacement.

tail -F /var/log/app.log

Parameters, options and clauses

Option / clauseDescription
-n, --lines=NUMPrint the last NUM lines (default 10).
-c, --bytes=NUMPrint the last NUM bytes.
-f, --followKeep reading as the file grows.
-FFollow by name and retry if the file is replaced or recreated.
-q, --quietNever print file headers.
-v, --verboseAlways print file headers.
Safety note

Review a command and its target before running it. Commands that alter files, services, accounts, disks, permissions or databases may be difficult to reverse. Test in a safe environment and keep backups.

Official reference ↗Back to directory