From owner-freebsd-questions@FreeBSD.ORG Sun Apr 15 08:29:50 2007 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id B3A2E16A406 for ; Sun, 15 Apr 2007 08:29:50 +0000 (UTC) (envelope-from zhangweiwu@realss.com) Received: from bossdog.realss.com (bossdog.realss.com [211.157.108.128]) by mx1.freebsd.org (Postfix) with ESMTP id 4756613C45D for ; Sun, 15 Apr 2007 08:29:50 +0000 (UTC) (envelope-from zhangweiwu@realss.com) Received: from localhost (unknown [127.0.0.1]) by bossdog.realss.com (Postfix) with ESMTP id F07F11C000D for ; Sun, 15 Apr 2007 16:30:07 +0800 (CST) Received: from bossdog.realss.com ([127.0.0.1]) by localhost (bossdog.realss.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 00925-18 for ; Sun, 15 Apr 2007 16:30:07 +0800 (CST) Received: from [218.193.55.195] (28.226.77.125.board.xm.fj.dynamic.163data.com.cn [125.77.226.28]) by bossdog.realss.com (Postfix) with ESMTP id CA2CD1C000C for ; Sun, 15 Apr 2007 16:30:06 +0800 (CST) From: Zhang Weiwu To: f-q In-Reply-To: <20070415054023.GA6596@holestein.holy.cow> References: <1176603461.20274.12.camel@joe.realss.com> <20070415054023.GA6596@holestein.holy.cow> Content-Type: text/plain Organization: Real Softservice Date: Sun, 15 Apr 2007 16:26:57 +0800 Message-Id: <1176625617.22011.16.camel@joe.realss.com> Mime-Version: 1.0 X-Mailer: Evolution 2.8.2 Content-Transfer-Encoding: 7bit X-Virus-Scanned: amavisd-new at bossdog.realss.com Subject: Re: [OT] can sed handle this situation? (might require variable) X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Apr 2007 08:29:50 -0000 On Sun, 2007-04-15 at 01:40 -0400, Parv wrote: > in message <1176603461.20274.12.camel@joe.realss.com>, > wrote Zhang Weiwu thusly... > > > > Dear list. I could not find a mailing list about 'sed' (there is > > an very inactive Yahoo Group though) so I wish to try some luck > > here. > > Try, comp.unix.misc newsgroup. > > > > I've got a situation that looks like require using variable and > > not possible to process with sed. But I am not sure. Can someone > > suggest me if this task is out of scope of sed? > > Try some variation of what Garret suggested if sed is the > requirement and skip rest of the message. Thank you very much for all of you providing insights. I have not yet tried all possibilities in sed but I have just discovered it's relatively easy to handle this task in awk with this script: /^$/ { print "createTimestamp:", timeStamp; timeStamp = ""; } /^ahkCreateTimeStamp:/ { timeStamp = $2;} /^createTimestamp:/ { if (timeStamp == "") timeStamp = $2; } $0 !~ /^ahkCreateTimeStamp:/ && $0 !~ /^createTimestamp:/ { print; }