awk

Hi,

I need to create a output of this:

This is the input:

-------- txt file ------

site: se
exclude: c:\iptt
exclude: c:\ern
site: de
exclude: d:\ee
site: fr
exclude: c:\we
exclude: c:\ed
exclude: c:\ew

----------------------

This should be the output:

se,c:\iptt
se,c:\ern
de,d:\ee
fr,c:\we
fr,c:\ed
fr,c:\ew

Can that be done with awk ? or maybe nawk ?

Thanks in advanced.

 awk '/^site/ { val=$2; next} { print val, ",", $2 } ' filename > newfilename
1 Like