
Hi Marcus, I copied your example into a file (because I do not have a RPM based Linux at hand)
Repo-id : extras Repo-name : CentOS-5 - Extras Repo-updated : Tue Oct 25 03:18:58 2011 Repo-pkgs : 237 Repo-size : 124 M Repo-baseurl : http://ftp.swin.edu.au/centos/5/extras/x86_64/, : http://ftp.monash.edu.au/pub/linux/CentOS/5/extras/x86_64/, : http://mirror.aarnet.edu.au/pub/centos/5/extras/x86_64/ Repo-expire : 3,600 second(s) (last: Wed Nov 16 12:39:48 2011)
and piped into the following quick&dirty awk script: #!/usr/bin/awk -f $1=="Repo-name" {printf "'"; for (i=3; i<NF; i++) printf $i" "; printf $NF"' "} $1=="Repo-baseurl" {url=1; comma=match($NF,","); if (comma) out=substr($NF,1,comma-1); else out=$NF printf "'"out"' "} url=1 {if ($1==":") { comma=match($NF,","); if (comma) out=substr($NF,1,comma-1); else out=$NF printf "'"out"' "} else url=0} The result is: $ cat /tmp/mom | /tmp/mom.awk 'CentOS-5 - Extras' 'http://ftp.swin.edu.au/centos/5/extras/x86_64/' 'http://ftp.monash.edu.au/pub/linux/CentOS/5/extras/x86_64/' 'http://mirror.aarnet.edu.au/pub/centos/5/extras/x86_64/' (One line actually) Happy with it? Sorry for not debugging your sed scripts, I have a problem to understand my own;-) (That's why I prefer awk as long as it seems doable by awk, it is easier to understand and read than sed) Regards Peter