tail command (Linux / bash / sh / zsh)
What it does
Print the end of input and optionally follow appended data. When people search for the tail command linux log, they usually want tail's everyday flags, safe examples, and how it differs from related tools. Below you'll find syntax, options, and copyable examples for Bash/sh/zsh.
Print the end of input and optionally follow appended data.
Syntax
tail [OPTION]... [FILE]...
Common options
| Flag / option | Meaning |
|---|---|
| -n N | Print the last N lines. |
| -f | Follow a growing file. |
| -F | Follow by name and retry after rotation. |
| -c N | Print the last N bytes. |
Practical examples
Last lines
tail -n 50 app.log
Shows the latest fifty log lines.
Follow log
tail -f server.log
Prints new lines as they arrive.
Survive rotation
tail -F /var/log/app.log
Reopens the named log after replacement.
Common mistakes
- Using `-f` for rotated logs when `-F` is needed.
- Leaving background follow processes running after a script finishes.
Related commands
- headPrint the beginning of files or standard input.
- journalctlQuery and follow logs stored by the systemd journal.
- lessPage through text interactively without loading it all at once.
- grepSearch text for lines matching a pattern.
- Where-ObjectFilter pipeline objects by property values or a script block predicate.
- catConcatenate files and write their contents to standard output.
- Get-ContentRead file content or provider data as a stream of objects.
- echoWrite arguments and shell-expanded values to standard output.
FAQ
What does tail do in Linux?
Print the end of input and optionally follow appended data.
How do I use tail from the terminal?
Start with `tail [OPTION]... [FILE]...`, then choose only the options needed for the task.
What is a practical tail example?
Try `tail -n 50 app.log` — Shows the latest fifty log lines.
Can I use tail in a shell script?
Yes. tail works in Bash, sh, and Zsh, but scripts should handle quoting, errors, and command output explicitly.
Browse the full Linux and Windows command reference to search more bash, CMD, PowerShell, Conda, and GitHub CLI commands.