home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  

UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 25.13 pushin: Squeeze Out Extra White Space Chapter 25
Showing What's in a File
Next: 25.15 Finer Control on tail

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 


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

Previous: 25.13 pushin: Squeeze Out Extra White Space UNIX Power Tools Next: 25.15 Finer Control on tail
25.13 pushin: Squeeze Out Extra White Space Book Index 25.15 Finer Control on tail

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System