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: Bob Proulx
Subject: Re: Add a --timestamp option to cat?
Date: Thu, 3 Mar 2011 15:02:43 -0700
User-agent: Mutt/1.5.20 (2009-06-14)

Adam Sjøgren wrote:
> 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

Thank you for thinking about improving the coreutils.  However I am
very strongly in disagreement that 'cat' should have such a
timestamping pretty printing feature.  File concatenation tools should
not be adding timestamps nor pretty printing.

The feature of pretty printing with timestamps itself is interesting.
It is easily enough accomplished with a script though

  perl -ple '$_ = localtime." ".$_;'

but just complicated enough that a helper might be nice.  I am not
opposed to it by itself.  But I am strongly opposed to the creeping
feature of it going into a file concatenation program.  That just
isn't the right place for it.

To make this sound a little less harsh let me say the following.
The general pattern is that someone who is unhappy with the current
state of the world proposes a substantial change.  They post this
idea.  The worry amongst someone who opposes the change is that it
might go through if not opposed.

> Rather similar to what cat --number does, only with timestamps.

The problem with using cat -n as an example of this is that cat -n is
the counter example of a feature that should never have gone into cat.
The proposal to follow it with more provides an excellent datapoint.

> 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!

I am not sure where the right place to put such a feature.  Off the
top of my head the closest in coreutils would seem to be 'pr' but even
there I don't know.  Perhaps it would be worthy of a new utility.  Or
perhaps in yet a different filter from outside coreutils.  The feature
is one that modifies the input to the output as a filter for pretty
printing and therefore pr seems like the better class of program for
this type of behavior of pretty printing output.

Bob



reply via email to

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