Re: [OT] simpliest way to process this data file



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

_______________________________________________
freebsd-questions@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscribe@xxxxxxxxxxx"



Relevant Pages

  • [OT] simpliest way to process this data file
    ... I know this is OT but we got so many sysops here and this might be ... easy solution (tried to play with "N" command a lot of times). ... how to do it in awk but I am pretty interested to learn a second ...
    (freebsd-questions)
  • Re: Removing lines from a plain text file
    ... Apparently there is no simple command. ... > and put prune in a cron job. ... > size by removing the excess from the beginning of the file. ... date from the past and use awk to search through the file for it and discard ...
    (comp.unix.sco.misc)
  • Re: Closing a field
    ... I thought of the same solution, that of using the field number count as the discriminant, mainly because I don't have any idea how to use AWK to validate a field as a number. ... The treatment of tabs as an alias for spaces in some POSIX is motivating me to stay away from them. ... already have a filter called 'join' so why not use AWK to create a filter called 'select' and for other SQL commands as well. ... I'd want to call the script by its SQL command name and use it as an SQL-like Unix pipe filter. ...
    (comp.lang.awk)
  • Re: Directory Size problem
    ... That's what the ln command is all about. ... the file strorage is not reclaimed until the last open channel is ... If a file is opened by multiple channels then this phenomenum will ... Play with these commands and you'll see all of this stuff come into play. ...
    (Fedora)
  • Re: Problem while executing "system " in awk
    ... There is a file(named myno) containg phone numbers. ... I've written following awk prog ... Please suggest why my systemcommand is not executing ... it is possible that the shell is seeing your command as ...
    (comp.lang.awk)