tech-userlevel archive

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

Re: Proposal: Add option to add dates to write(1)



On Wed, Jun 27, 2012 at 10:07:36PM +0200, Julian Fagir wrote:
 > The following function would do the work:
 > 
 > prependate()
 > {
 >   while true; do
 >     read line
 >     s=$(date +"${1:-%X %x: }")
 >     echo "$line" | awk "{ sub(\"^\", \"$s\"); print; fflush }"
 >   done
 > }

prependate() { awk '{ printf "%s %s\n", strftime("%x %X"), $0; fflush; }' }

 > Anyway, with comments, error handling, proper indenting, etc., you won't end
 > up with thaat much less lines than in C.

Buncombe. :-)

-- 
David A. Holland
dholland%netbsd.org@localhost


Home | Main Index | Thread Index | Old Index