From owner-freebsd-questions@FreeBSD.ORG Thu Apr 26 06:55:16 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 D809C16A402 for ; Thu, 26 Apr 2007 06:55:16 +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 2FC4A13C469 for ; Thu, 26 Apr 2007 06:55:16 +0000 (UTC) (envelope-from zhangweiwu@realss.com) Received: from localhost (unknown [127.0.0.1]) by bossdog.realss.com (Postfix) with ESMTP id AE58A1D85B7 for ; Thu, 26 Apr 2007 14:55:31 +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 19497-01 for ; Thu, 26 Apr 2007 14:55:29 +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 8FF071D85B6 for ; Thu, 26 Apr 2007 14:55:29 +0800 (CST) From: Zhang Weiwu To: freebsd-questions@freebsd.org In-Reply-To: <1177557488.22129.16.camel@joe.realss.com> References: <1177557488.22129.16.camel@joe.realss.com> Content-Type: text/plain Organization: Real Softservice Date: Thu, 26 Apr 2007 14:51:29 +0800 Message-Id: <1177570289.22129.39.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] 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 06:55:16 -0000 An example that is probably not simple enough: awk 'BEGIN { FS="\n"; RS="\n\n";} { print ""; print $NF; for (i=1; i 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