Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 26 Apr 2007 14:51:29 +0800
From:      Zhang Weiwu <zhangweiwu@realss.com>
To:        freebsd-questions@freebsd.org
Subject:   Re: [OT] simpliest way to process this data file
Message-ID:  <1177570289.22129.39.camel@joe.realss.com>
In-Reply-To: <1177557488.22129.16.camel@joe.realss.com>
References:  <1177557488.22129.16.camel@joe.realss.com>

next in thread | previous in thread | raw e-mail | index | archive | help
An example that is probably not simple enough:

awk 'BEGIN { FS="\n"; RS="\n\n";} { print ""; print $NF; for (i=1; i<NF; i++) print $i;}' 


On Thu, 2007-04-26 at 11:18 +0800, Zhang Weiwu wrote:
> 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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1177570289.22129.39.camel>