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

next in thread | raw e-mail | index | archive | help
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?1177557488.22129.16.camel>