From owner-freebsd-questions@FreeBSD.ORG Thu Apr 26 03:21:54 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 6E0AC16A400 for ; Thu, 26 Apr 2007 03:21:54 +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 EB9CA13C458 for ; Thu, 26 Apr 2007 03:21:53 +0000 (UTC) (envelope-from zhangweiwu@realss.com) Received: from localhost (unknown [127.0.0.1]) by bossdog.realss.com (Postfix) with ESMTP id 836681D85B7 for ; Thu, 26 Apr 2007 11:22:05 +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 17404-05 for ; Thu, 26 Apr 2007 11:22:03 +0800 (CST) Received: from [218.193.55.195] (237.16.61.59.board.xm.fj.dynamic.163data.com.cn [59.61.16.237]) by bossdog.realss.com (Postfix) with ESMTP id 6663A1D85B6 for ; Thu, 26 Apr 2007 11:22:03 +0800 (CST) From: Zhang Weiwu To: freebsd-questions@freebsd.org Content-Type: text/plain Organization: Real Softservice Date: Thu, 26 Apr 2007 11:18:07 +0800 Message-Id: <1177557488.22129.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: [OT] simpliest way to process this data file 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: Thu, 26 Apr 2007 03:21:54 -0000 I know this is OT but we got so many sysops here and this might be something very easy for them to drop me a quick answer? I have a data file formatted like this each block of data consist of several lines; blocks are separated by empty lines like this This is a block of data with lines and another block of data The task is to move the last line of each block to the first line of the block. So the processed data look like this: with lines This is a block of data data and other block of I have tried a lot reading info pages of sed still cannot figure out an easy solution (tried to play with "N" command a lot of times). I know how to do it in awk but I am pretty interested to learn a second language and I really think sed or other tools should be able to handle this:) -- Zhang Weiwu Real Softservice http://www.realss.com +86 592 2091112