johny2502
johny2502

Reputation: 51

Custom field and row separator in AWK (bash)

I have data in this order :

Person:Joe  
Age:24 
City:PH
---

Person:Joe 
Age:22  
City:NY

And i want to achieve data in this format

John|24|PH
Joe|22|NY

I tried with custom RS and OFS but i can't do this property.

Upvotes: 0

Views: 53

Answers (1)

Ed Morton
Ed Morton

Reputation: 203493

$ awk -v RS= -F'[:[:space:]]+' -v OFS='|' '{print $2, $4, $6}' file
Joe|24|PH
Joe|22|NY

Upvotes: 2

Related Questions