Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 19 May 2003 13:30:17 +0200
From:      Simon Barner <barner@in.tum.de>
To:        Andy Farkas <andyf@speednet.com.au>
Cc:        freebsd-questions@FreeBSD.ORG
Subject:   Re: timestamping a text stream
Message-ID:  <20030519113017.GA46308@zi025.glhnet.mhn.de>
In-Reply-To: <20030519174723.B93323-100000@hewey.af.speednet.com.au>
References:  <20030519174723.B93323-100000@hewey.af.speednet.com.au>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi,

> Does anybody know of a program similar to script(1) or tee(1) that will
> timestamp each line of input as it happens?

You can use this perl script:

#!/usr/bin/perl -w
# This is timestamp.pl

use strict;

my $line=undef;
my $stamp;
while (defined ($line = <>)) {
	$stamp = localtime (time ());
	print ("$stamp: $line");
}

echo "foo" | ./timestamp.pl
Mon May 19 13:25:31 2003: foo

> Ultimately, I want each line of a `make buildworld` timestamped.

So, something like 'make buildworld 2>&1 | ./timestamp.pl' is what you
want.

Simon



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030519113017.GA46308>