From owner-freebsd-questions@FreeBSD.ORG Sun Apr 15 02:20:15 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 3929316A403 for ; Sun, 15 Apr 2007 02:20:15 +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 66FEE13C45E for ; Sun, 15 Apr 2007 02:20:14 +0000 (UTC) (envelope-from zhangweiwu@realss.com) Received: from localhost (unknown [127.0.0.1]) by bossdog.realss.com (Postfix) with ESMTP id D94021C000D for ; Sun, 15 Apr 2007 10:20:24 +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 30084-14 for ; Sun, 15 Apr 2007 10:20:24 +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 B05B01C000C for ; Sun, 15 Apr 2007 10:20:23 +0800 (CST) From: Zhang Weiwu To: freebsd-questions@freebsd.org Content-Type: text/plain Organization: Real Softservice Date: Sun, 15 Apr 2007 10:17:41 +0800 Message-Id: <1176603461.20274.12.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: [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 02:20:15 -0000 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. Sorry for OT. 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? The input document is sections of data separated by an empty new line; in each section there are a few lines. It's like this: dn: uid=ABB,ou=contacts,ou=china,dc=ahk,dc=de uid: ABB ahkCreateTimeStamp: 19960328000000Z creatorsName: cn=manager,dc=ahk,dc=de createTimestamp: 20060425094550Z dn: uid=paulblome,ou=contacts,ou=china,dc=ahk,dc=de uid: paulblome sn: Blome createTimestamp: 20060417071950Z modifiersName: cn=manager,dc=ahk,dc=de modifyTimestamp: 20060630094026Z The above sample showed two sections in input data. It's required to process the data in following rule: if a data section has "ahkCreateTimeStamp: abc", replace it with "createTimestamp: abc" and remove the original "createTimestamp: def" line; That is, the result data of above sample should be: dn: uid=ABB,ou=contacts,ou=china,dc=ahk,dc=de uid: ABB createTimestamp: 19960328000000Z creatorsName: cn=manager,dc=ahk,dc=de dn: uid=paulblome,ou=contacts,ou=china,dc=ahk,dc=de uid: paulblome sn: Blome createTimestamp: 20060417071950Z modifiersName: cn=manager,dc=ahk,dc=de modifyTimestamp: 20060630094026Z -- Zhang Weiwu Real Softservice http://www.realss.com +86 592 2091112