
On Thu, Nov 17, 2011 at 12:36, Peter Ross <Peter.Ross@bogen.in-berlin.de> wrote:
Hi Marcus,
first I had an error (spot the url=1 instead of url==1 condition?) so it did not work that well for multiple appearences.
However, this one should do:
#!/usr/bin/awk -f { if ($1=="Repo-name") { printf "'"; for (i=3; i<NF; i++) printf $i" "; printf $NF"' "; } if ($1=="Repo-baseurl") { url=1; comma=match($NF,","); if (comma) out=substr($NF,1,comma-1); else out=$NF; printf "'"out"' "; } else { if (url==1) { if ($1==":") { comma=match($NF,","); if (comma) out=substr($NF,1,comma-1); else out=$NF; printf "'"out"' "; } else {url=0; print "";} } } }
I made it a bit more "C-like" in appearance but the logic is the same.
Thanks Peter, this one works perfectly! Is it possible to run the above on the command line so I can process through the pipeline without an external awk script? I've been playing with the formatting but keep getting "unexpected newline or end of string" along with plenty of syntax errors... Marcus. -- Marcus Furlong