Add a timestamp to every STDOUT line
I found this useful for debugging and just handy to have in the toolbox. Alias within your profile!
Use:
./anyscript_you_choose | ./addtime
[perl]
#!/bin/perl -w
# filename: ./addtime
my($old)=select(STDOUT);
$|=1;
select(STDIN);
$|=1;
select ($old);
while(<>)
{
my($sec,$min,$hour,$mday,$mon,$year,$wday,$ydat,$isdst)= localtime (time);
printf “%02d:%02d:%4d %02d:%02d:%02d %s”,$mday,$mon+1,$year+1900,$hour,$min,$sec,$_;
}
[/perl]