#!/usr/bin/perl use warnings; use strict; use Time::HiRes qw{ time }; my $start = time; while (<>) { printf '%3.7f | %s', time - $start, $_; }
Test run:
for i in {1..10} ; do sleep .2 ; echo $i ; done | prepend.pl
If you want to overwrite a line, don't output "\n" at its end, but use "\r" instead, it will move the cursor to the beginning of the same line.
Update: See Time::HiRes , printf, and Quote and Quote like Operators.
($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
In reply to Re: How to Prepending a timestamp to each line of output from a command
by choroba
in thread How to Prepending a timestamp to each line of output from a command
by jnarayan81
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |