I have a REST API that gives utilized via cURL the output as below:
OK:
groupId: 27
groupPath: My Organization\Management\xyz
groupId: 32
groupPath: My Organization\Management\Database Host\xyz
I want the output to be formatted to this:
groupId groupPath
27 My Organazation\Management\xyz
32 My Organization\Management\Database Host\xyz
Any leads on this?
Thanks in advance!
CodePudding user response:
When you read a groupId:
line, save the group ID in a variable. When you read a groupPath:
line, substitute the saved group ID into the line and print it.
awk 'BEGIN {print "groupId groupPath"} /groupId:/ { g = $2 } /groupPath:/ {$1 = g;print}'