tail

From NetBSD Wiki

Jump to: navigation, search

The tail(1) command works just like head, only instead of the top 10 lines, it shows the bottom 10 lines of a file:

$ tail wocky.txt

"And, has thou slain the Jabberwock?
  Come to my arms, my beamish boy!
  O frabjous day! Callooh! Callay!'
  He chortled in his joy.

`Twas brillig, and the slithy toves
  Did gyre and gimble in the wabe;
  All mimsy were the borogoves,
  And the mome raths outgrabe.
$

As with head, you can change the default number of lines by using the -n switch:

$ tail -n 2 wocky
  All mimsy were the borogoves,
  And the mome raths outgrabe.
$

tail(1) has one major difference with head: It supports an extra -f option ("follow"). This option tells tail(1) to wait for more input after it has read an end-of-file. This is nice for keeping a tap on some log you want to follow as it grows.

$ cat my-story
To be or not to be...
$ tail -f my-story
To be or not to be...
<now tail hangs at EOF.  Switch to another terminal and enter:>
$ echo "WTF is the answer?" >> my-story
<switch back, and it will show>
WTF is the answer?

You can of course just stop the process with ^C when you tire of waiting for more.

See also

View source code (Please report any bugs or suggestions here).

Retrieved from "http://wiki.netbsd.se/tail"
Personal tools