lundi 7 janvier 2019

AWK - match multiple patterns at once

I'm trying to process csv file to find patterns like 'duser=','dhost=' and 'dproc=' and once found print next string after. I have to use pattern match first due to fact that content of csv file is not constant. Field separators are not constant as well. Seems that below command works:

... | awk 'sub(/.*duser=/,""){print "User:",$1}

However, it works only for first pattern. After execution as you can guess, there are no more lines to process. Is there any option to execute above command 3 times with different pattern to get list of 3 columns?

I would like to achieve:

duser=AAA dhost=BBB dproc=CCC
duser=DDD dhost=EEE dproc=FFF
duser=GGG dhost=HHH dproc=III

Appreciate your help, thank you

Aucun commentaire:

Enregistrer un commentaire