Now that was interesting

Here's what I've come up with:
Code:
#!/bin/bash
tr ',=' '||' | awk -F\| '
function new() { if (line != "") print line; line=$1; last=""; }
function add(p) {
if (last == "")
line=line "=" p;
else if (p != last)
line=line "," p;
last=p;
}
NF==1 && $1~/^tomcat/ { new(); next; }
NF>1 { for (i=2; i<=NF; i++) add($i); }
END { new() }
'
Suppose the script is named summary.sh, you would run it like this:
Code:
./summary.sh </path/to/input/file >/path/to/result/file
This script assumes the following:
- The namespace begins with "tomcat" and has neither equals nor comma in it.
- The products have neither equals nor comma in them.
- The JAR paths have neither equals nor comma in them.
- There's at least one JAR path for a namespace else it is not printed.
- Out of two identical paths, only one is kept if they are side by side only, because the order of JARs is considered important as it may have impact on which version of a Java class your program will end-up using.
If any of the above is not true, changes are possible.
Yves.