I use something like that every day -- I have a script called notch.pl that outputs a blank line and the time after a new line of output arrives if it's a different minute that the previous line's time.
Here's the code:
I probably could use File::Tail as merlyn suggests but just threw it together because trying to#!/usr/bin/perl -w # Notch out time when lines from 'tail -f' arrive so that lines # from different minutes are separated by a timestamp. use strict; { my $lastMinute = (localtime)[1]; while(<>) { my $thisLine = $_; my $thisMinute = (localtime)[1]; if ( $thisMinute != $lastMinute ) { $lastMinute = $thisMinute; print "\n"; print scalar localtime; print "\n"; } print $thisLine; } }
Based on the amount of traffic that I see, I don't worry too much about it using an extra pipe or process.
Update Correct two typos .. the first of which I made again, and had to go back and fix again.
In reply to Re: Using pipe and reading from the stdin
by talexb
in thread Using pipe and reading from the stdin
by mellin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |