Re: Curious behavior: tail, grep, cut --- Bug?
From: Chris F.A. Johnson (cfajohnson_at_gmail.com)
Date: 06/28/05
- Next message: Analabha Roy: "Hardware Requirements for building a Linux PVR"
- Previous message: beefalo: "Re: Lynx Browser, fun stuff"
- In reply to: M_F_H: "Curious behavior: tail, grep, cut --- Bug?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 28 Jun 2005 17:22:10 -0400
On 2005-06-28, M_F_H wrote:
> Please explain this curiosity, seen on Fedora 4 and Knoppix 3.4:
>
> 1) tail -n200 /var/log/messages
> produces the last 200 lines of the main log file,
>
> 2) tail -n200 -F /var/log/messages
> produces the same as (1), but then prints any additional log entries that the
> system produces,
>
> 3) tail -n200 /var/log/messages | grep "IN=ppp0"
> finds the same lines as (1), but prints only the lines that contain the string
> "IN=ppp0",
>
> 4) tail -n200 /var/log/messages | grep IN=ppp0" | cut -b1-100
> prints the same results as (3), but only the first 100 bytes (i.e., characters)
> of each line are printed,
>
> 5) tail -n200 -F /var/log/messages | grep "IN=ppp0" | cut -b1-100
> is supposed to result in the same output as (4), and then print any additional
> lines that the log file gets that passes the grep filter. However, on every
> Linux machine I have tried, I typically get fewer lines than (4), truncated to
> the first 100 bytes of each line. And the update feature appears not to work.
> Same behavior whether one uses the -F or -f switch on tail.
It is caused by buffering.
--
Chris F.A. Johnson <http://cfaj.freeshell.org>
==================================================================
Shell Scripting Recipes: A Problem-Solution Approach, 2005, Apress
<http://www.torfree.net/~chris/books/cfaj/ssr.html>
- Next message: Analabha Roy: "Hardware Requirements for building a Linux PVR"
- Previous message: beefalo: "Re: Lynx Browser, fun stuff"
- In reply to: M_F_H: "Curious behavior: tail, grep, cut --- Bug?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|