[Chapter 25] 25.14 How to Look at the End of a File: tail
Author: Jerry Peek, Tim O'Reilly & Mike Loukides
Date: 1998-08-04T21:43:27Z

#

| Chapter 25 Showing What's in a File |

## 25.14 How to Look at the End of a File: tail

' TIM SAYS "SUBSECTIONS DON'T WORK" Let's say that you want to look at the end of some large file. For example, you've just sent some mail via UUCP (1.33) and want to find out whether it was handled correctly. But when you give the uulog command, you find out that the UUCP log file is 30 or 40 KB long, and you don't care about the whole thing - you certainly don't want to page through it until you get to the end. How do you handle this?

The tail command is just what you need in this situation. tail reads its input and discards everything except for the last ten lines (by default). Therefore, if you're pretty sure that the information you want is at the end of the file, you can use tail to get rid of the junk that you don't want. To use the uulog example:

>     % uulog | tail

This will give you the last ten lines of the UUCP log. If you need more or less than ten lines, look at article 25.15.

You can give tail one (and only one!) filename:

>     % tail somefile

There are many other situations in which tail is useful: I've used it to make sure that a job that produces a big output file has finished correctly, to remind me what the last piece of mail in my mailbox was about, and so on. You'll find tail important whenever you're interested only in the end of something.

- ML

25.13 pushin: Squeeze Out Extra White Space |  | 25.15 Finer Control on tail