tail - command in linux
displays last 10 lines of FILE to standard output / terminal / putty
syntax
tail [filename]
example
//displays last 10 lines by default
[user@host log]$ tail dmesg
displays last n lines with int argument
//displays last 20 lines
[user@host log]$ tail -20 dmesg
//displays last 30 lines
[user@host log]$ tail -30 dmesg
//displays last 40 lines
[user@host log]$ tail -40 dmesg
display continues stream, with -f option (follow option)
tail -f [file]
display continues stream along with grep
tail -f [file] | grep [pattern]
options
Option | Description |
---|---|
-c, --bytes=K | displays last K bytes; alternatively, use -c +K to output bytes starting with the Kth of each file |
-f, --follow | displays data continuously as the file grows |
-F | this is equally --follow=name --retry |
-n, --lines=K | displays the last K lines. default is last 10 lines |
--max-unchanged-stats=N | using option --follow=name, reopen a FILE which not updated after N (default 5) try to see if it has been unlinked or renamed, useful for log files. |
--pid=PID | using by option -f, tail will terminates after PID exits |
-q, --quiet, --silent | it will never output headers giving file names |
--retry | will keep try to open the file even when file is not accessible; this is useful when following by name, i.e., with --follow=name |
-s, --sleep-interval=N | using option -f, sleep tail for approximately N seconds (default 1.0) between iterations. |
-v, --verbose | displays headers giving file names |
--help | displays help information |
--version | displays version information |