[OT] simpliest way to process this data file

Zhang Weiwu zhangweiwu at realss.com
Thu Apr 26 06:55:16 UTC 2007


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



More information about the freebsd-questions mailing list