From owner-freebsd-current@FreeBSD.ORG Sat Aug 12 03:59:12 2006 Return-Path: X-Original-To: current@freebsd.org Delivered-To: freebsd-current@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7802816A4DF for ; Sat, 12 Aug 2006 03:59:12 +0000 (UTC) (envelope-from prvs=julian=372565577@elischer.org) Received: from a50.ironport.com (a50.ironport.com [63.251.108.112]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3395F43D49 for ; Sat, 12 Aug 2006 03:59:12 +0000 (GMT) (envelope-from prvs=julian=372565577@elischer.org) Received: from unknown (HELO [192.168.2.3]) ([10.251.60.35]) by a50.ironport.com with ESMTP; 11 Aug 2006 20:59:11 -0700 Message-ID: <44DD520F.4040403@elischer.org> Date: Fri, 11 Aug 2006 20:59:11 -0700 From: Julian Elischer User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.7.13) Gecko/20060414 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Sam Leffler References: <44DD4510.5070002@elischer.org> <44DD48C8.7000805@errno.com> <44DD509A.1080307@errno.com> In-Reply-To: <44DD509A.1080307@errno.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Cc: current@freebsd.org Subject: Re: suggested addition to 'date' X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 12 Aug 2006 03:59:12 -0000 Sam Leffler wrote: >Sam Leffler wrote: > > >>Julian Elischer wrote: >> >> >>>At various times I've wanted to add timestamps to logfiles as they are >>>generated.. >>> >>>usually this has involved perl or something to do it. >>> >>>finally I broke down and just added a small bit to date(1) >>> >>>the -s option tells date to add a timestamp on the front of every line >>>read in through stdin >>>and put it out through stdout. teh format of the datestamp is governed >>>exactly as usual so: >>> >>>%ls | ./date -s +"%+: " >>>Fri Aug 11 19:53:34 PDT 2006: CVS >>>Fri Aug 11 19:53:34 PDT 2006: Makefile >>>Fri Aug 11 19:53:34 PDT 2006: date >>>Fri Aug 11 19:53:34 PDT 2006: date.1 >>>Fri Aug 11 19:53:34 PDT 2006: date.1.gz >>>Fri Aug 11 19:53:34 PDT 2006: date.c >>>Fri Aug 11 19:53:34 PDT 2006: date.o >>>Fri Aug 11 19:53:34 PDT 2006: extern.h >>>Fri Aug 11 19:53:34 PDT 2006: netdate.c >>>Fri Aug 11 19:53:34 PDT 2006: netdate.o >>>Fri Aug 11 19:53:34 PDT 2006: vary.c >>>Fri Aug 11 19:53:34 PDT 2006: vary.h >>>Fri Aug 11 19:53:34 PDT 2006: vary.o >>>%ls | ./date -s +"%s: " >>>1155351474: CVS >>>1155351474: Makefile >>>1155351474: date >>>1155351474: date.1 >>>1155351474: date.1.gz >>>1155351474: date.c >>>1155351474: date.o >>>1155351474: extern.h >>>1155351474: netdate.c >>>1155351474: netdate.o >>>1155351474: vary.c >>>1155351474: vary.h >>>1155351474: vary.o >>>% >>>I attach the diff. >>>I'm sure that someone who is a more competent practicioner of userland C >>>programming >>>can probably clean this up abit. >>> >>>do people think this is a worthwhile addition? >>> >>>An easy to imagine use for this is to add it in the makefile for /usr so >>>that "make buildworld" datestamped its output >>>(for example). >>> >>>it makes it easy to timestamp output from a console logger for example: >>> >>> >>pbj% ls | sed -e "s/^/`date +'%+: '`/" >>Fri Aug 11 20:18:05 PDT 2006: Desktop >>Fri Aug 11 20:18:05 PDT 2006: Desktop DB >>Fri Aug 11 20:18:05 PDT 2006: Desktop DF >>Fri Aug 11 20:18:05 PDT 2006: Documents >>Fri Aug 11 20:18:05 PDT 2006: Library >>Fri Aug 11 20:18:05 PDT 2006: Movies >> ... >> >> > >I figure you won't like that 'cuz it pastes the same date stamp on every >line so here's another offering: > >pbj% ls | awk '{ "date +'%+'" | getline x; print x ": " $0; }' >Fri Aug 11 20:50:42 PDT 2006: Desktop >Fri Aug 11 20:50:42 PDT 2006: Desktop DB >Fri Aug 11 20:50:42 PDT 2006: Desktop DF >Fri Aug 11 20:50:42 PDT 2006: Documents >Fri Aug 11 20:50:42 PDT 2006: Library >Fri Aug 11 20:50:42 PDT 2006: Movies > > It still does a fork followed by an exec of shell followed by an exec of date once for every line. Do you think it is a BAD thng to add or are you just pointing out that it is possinle to do it in other ways?