Tille - I can see you, read those man pages!   Tille's Site

Exercise on awk

Problem

This is from the Linux Documentation Project, for which I write and help out from time to time. Binh Nguyen, author of the Linux dictionary, wanted a way to convert his text file, containing thousands of Linux-related words, together with their definitions, to DocBook XML.

The input file contains entries, separated by blank lines. The word and its definition are separated from eachother by tabs:

Word	definition in very long line

word	long line

otherword	more longline

testword	looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong line, but i mean really looooooooooooooooooooooooooooooooooooooooooooooooooong.

The output should look like this:

<row>
<entry>Word</entry><entry>definition in very long line</entry>
</row>

<row>
<entry>word</entry><entry>definition in very long line</entry>
</row>
...

Solution

Click here for a possible solution.

Home
© 1995-2010 Machtelt Garrels - tille - Powered by vIm - Best viewed with your eyes - Validated by W3C - Last update 20100511