10 Jan 2016 mones   » (Journeyer)

Oneliner for today

Unfortunately I'm still busy trying to finish the documentation of my M.Sc. project. This one was built after several attempts to convert the tables for the use case descriptions spread through several AsciiDoc files into a list of 3rd level titles joining both the use case Id and title (and some dummy content to keep the processor happy):

grep --after-context=1 '^|Identificador' "$a" *_cu_*.txt 
| cut -f3 -d\| 
| sed 's,^--$,,;s,^\+,,' 
| sed ':a;N;$!ba;s,\n\n,\n,g' 
| sed ':a;N;$!ba;s,\+\n,~,g' 
| awk -F~ '{print $1 " ``"$2"\47\47"}' 
| perl -n -e '
use open qw(:std :utf8);
chomp; $n = length;
print "$_\n" . "^" x $n . "\n\nLorem ipsum...\n\n";
'


Imagine it all in one single line, of course. It's an awful beast, but it worked!

It required several visits to google to know how to properly replace newlines with sed, how to print single quotes with awk and how to make perl's lenght function behave as desired with UTF-8 input, though I was already aware of this one ;-)

Syndicated 2016-01-10 20:28:45 from Ricardo Mones

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!