From owner-freebsd-current@FreeBSD.ORG Fri Aug 18 14:45:31 2006 Return-Path: X-Original-To: freebsd-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 4C1B916A4FC for ; Fri, 18 Aug 2006 14:45:31 +0000 (UTC) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (lurza.secnetix.de [83.120.8.8]) by mx1.FreeBSD.org (Postfix) with ESMTP id BAD5243D79 for ; Fri, 18 Aug 2006 14:45:27 +0000 (GMT) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (fgjajc@localhost [127.0.0.1]) by lurza.secnetix.de (8.13.4/8.13.4) with ESMTP id k7IEjB3M020039; Fri, 18 Aug 2006 16:45:17 +0200 (CEST) (envelope-from oliver.fromme@secnetix.de) Received: (from olli@localhost) by lurza.secnetix.de (8.13.4/8.13.1/Submit) id k7IEjA9f020038; Fri, 18 Aug 2006 16:45:10 +0200 (CEST) (envelope-from olli) Date: Fri, 18 Aug 2006 16:45:10 +0200 (CEST) Message-Id: <200608181445.k7IEjA9f020038@lurza.secnetix.de> From: Oliver Fromme To: freebsd-current@FreeBSD.ORG, julian@elischer.org In-Reply-To: <44E3BFD8.6040901@elischer.org> X-Newsgroups: list.freebsd-current User-Agent: tin/1.8.0-20051224 ("Ronay") (UNIX) (FreeBSD/4.11-STABLE (i386)) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.1.2 (lurza.secnetix.de [127.0.0.1]); Fri, 18 Aug 2006 16:45:17 +0200 (CEST) X-Mailman-Approved-At: Fri, 18 Aug 2006 14:51:12 +0000 Cc: 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: Fri, 18 Aug 2006 14:45:31 -0000 Julian Elischer wrote: > BTW I chose 's' without any research.. Date only has the short getopt so > '--' doesn't work, but > there are lots of unsed letters.. a quick survey suggests maybe -p (pipe?) > (suggestions welcome) my favourites of s and f are already used on one > system or another. There's another possibility, which doesn't require a new option letter at all. You could add a new escape sequence to the format string, e.g. "%*". Whenever date(1) is called with a format string containing that sequence, it goes into filter mode and replaces the sequence with the current line. That would also enable you to be more flexible with the placement of the timestamps. For example: $ printf 'foo\nbar\nbaz\n' | date +'%H:%M:%S %*' 16:39:58 foo 16:39:58 bar 16:39:58 baz Best regards Oliver PS: Personally I would recommend installing gnu-awk (it was formerly part of the FreeBSD base system, but it was replaced by a crippled awk, unfortunately), instead of hacking date. I always install gnu-awk because it's so useful. $ printf 'foo\nbar\nbaz\n' | gawk '{print strftime("%T"), $0}' 16:41:06 foo 16:41:06 bar 16:41:06 baz -- Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing Dienstleistungen mit Schwerpunkt FreeBSD: http://www.secnetix.de/bsd Any opinions expressed in this message may be personal to the author and may not necessarily reflect the opinions of secnetix in any way. "anyone new to programming should be kept as far from C++ as possible; actually showing the stuff should be considered a criminal offence" -- Jacek Generowicz