Using awk to split line with multiple string delimiters

Viewed 8497

I have a file called pet_owners.txt that looks like:

petOwner:Jane,petName:Fluffy,petType:cat
petOwner:John,petName:Oreo,petType:dog
...
petOwner:Jake,petName:Lucky,petType:dog

I'd like to use awk to split the file using the delimiters: 'petOwner', 'petName', and 'petType' so that I can extract the pet owners and pet types. My desired output is:

Jane,cat
John,dog
...
Jake,dog

So far I've tried:

awk < pet_owners.txt -F'['petOwner''petName''petType']' '{print $1 $3}'

but the result is a bunch of newlines.

Any ideas for how I can achieve this?

3 Answers
Related