coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Add a --timestamp option to cat?


From: Ondrej Vasik
Subject: Re: Add a --timestamp option to cat?
Date: Thu, 3 Mar 2011 17:41:00 -0500 (EST)

Hi,
what about

$ (echo A; sleep 2; echo B; sleep 3; echo C) | awk '{print strftime("%D 
%H:%m:%S",systime()) " " $0}' >some_program.log

I know awk is quite a big gun, but in most cases it should work...

Ondrej Vasik

----- Original Message -----
> Hi.
> 
> I often have programs that output stuff I would like have logged with
> timestamps, but they don't print timestamps themselves. I have been
> using various shell-scripts/hacks calling date(1) to wrap them.
> 
> I think it would be really great to be able to just go:
> 
> $ some_program | cat --timestamp > some_program.log
> 
> Rather similar to what cat --number does, only with timestamps.
> 
> I have made a little patch adding that functionality in a topic-branch
> called "timestamp" in my local clone of the coreutils git-repository:
> 
> * http://koldfront.dk/git/coreutils/commit/?h=timestamp
> 
> (git clone http://koldfront.dk/git/coreutils will clone my repo.)
> 
> Example:
> 
> $ (echo A; sleep 2; echo B; sleep 3; echo C) | ./cat --timestamp
> 2011-03-03 21:30:19 A
> 2011-03-03 21:30:21 B
> 2011-03-03 21:30:24 C
> $ (echo A; echo B; echo C) | ./cat --number
> 1 A
> 2 B
> 3 C
> $
> 
> I was wondering whether something like this could be considered for
> inclusion, or if there is some other/better avenue I should pursue?
> 
> Any advice/comments/etc. welcome. Thanks!
> 
> Best regards,
> 
> Adam
> 
> --
> "I always liked songs with parentheses in the title." Adam Sjøgren
> address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]