RSS Subscription
Linux Howtos & Tutorials

Enter your email:

Delivered by


NOTE:New tutorials are from LinuxCareer.com

Poll

Do you own or wish to have iPhone?
 


Linux eBooks FREE Download
A guide to programming Linux kernel modules
Introduction to Linux - A Hands on Guide
A Newbie's Getting Started Guide to Linux

Linux from Scratch - Create Your Own Linux System - Free eBook

Linux: The Hacking Solution (v.3.0)

SQLite 3 with PHP Essential Training – Free Video Training Tutorials

This guide will introduce you to the world of GNU/Linux

The GNU/Linux Advanced Administration

A Complete Beginner's Manual for Ubuntu 10.04 (Lucid Lynx)

Advanced Bash-Scripting Guide

Set up, maintain, and secure a small office email server

Partner Linux Sites:
How-To.LinuxCareer.com
Jobs.LinuxCareer.com
TuxMachines
Monsterb
LinuxBloggers
AdamsInfo
LinuxScrew
All For Linux

tail

Article Index
1. Name
2. Synopsis
3. Frequently used options
4. Examples

1. Name

tail [man page] - output the last part of files

2. Synopsis

tail [OPTION]... [FILE]... 

3. Frequently used options

-c, --bytes=N
      output the last N bytes
-f, --follow[={name|descriptor}]
      output appended data as the file grows; -f, 
      --follow, and --follow=descriptor are
      equivalent
-n, --lines=N
      output the last N lines, instead of the last 10 

4. Examples

Lets create sample file. This file will contain names of all directories in /var/. We can also number each line for better overview.

for f in $( ls /var/ ); do echo $f; done | nl > file1 

tail - create sample file
By default a tail command displays last 10 lines of given file.

tail 

tail command displays last 10 lines
To display just last 3 lines from this file we use -n option:

tail -n 3 file1 

tail - display last 3 lines
Moreover the same output can be produced by command:

tail -3 file1 

tail - display last 3 lines without -n

To use tail command on byte level we can use -c option. This option will make tail command to display last 4 bytes (4 characters) if a given file:

tail -c 4 file1 

tail command on byte level
If you wonder why we can see only 3 characters, use od command to see where the 4th byte is:

tail -c 4 file1 | od -a 

tail command on byte level and od
Another very useful option for tail command is -f. This option will continuously display a file as it is dynamically edited by another process. This option is very useful for watching log files.

tail -f /var/log/syslog 

Share this linux post:

Submit tail in Delicious Submit tail in Digg Submit tail in FaceBook Submit tail in Google Bookmarks Submit tail in Stumbleupon Submit tail in Technorati Submit tail in Twitter
 
Comments for this page are closed !!!
Please visit our new Linux Forum for additional help or discussion.


Linux eBooks FREE Download