in reply to How to Prepending a timestamp to each line of output from a command
Hmm, gnomon is a neat little tool. Just for the heck of it, here's a really simple Perl version (works on Linux, probably not on Windows):
#!/usr/bin/env perl use warnings; use strict; use IO::Select; use Time::HiRes qw/ gettimeofday tv_interval /; my $sel = IO::Select->new(\*STDIN); $|=1; my $t0 = [gettimeofday]; while (1) { my $line; if ($sel->can_read(.1)) { defined( $line = <STDIN> ) or last } printf "%7.3f | %s", tv_interval($t0), $line//"\r"; $t0 = [gettimeofday] if defined $line; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to Prepending a timestamp to each line of output from a command
by jnarayan81 (Sexton) on Jun 07, 2017 at 13:08 UTC | |
by haukex (Archbishop) on Jun 07, 2017 at 13:50 UTC |