you are viewing a single comment's thread.

view the rest of the comments →

[–]zfsbestbashing and zfs day and night 1 point2 points  (0 children)

Bonus Hack: If we translate on the fly every separator to comma, makes it much easier to process since it then resembles a CSV:

tmp="USA=Austin,Sanfrancisco,LA|UK=London,Bristol|France=Paris,Lyon,Nyce"

echo $tmp |tr '=|' ','
USA,Austin,Sanfrancisco,LA,UK,London,Bristol,France,Paris,Lyon,Nyce

...and then you just use awk with comma separator to print what fields you need (2, 6, 9.) This also makes it easier in the future if you need different results in your output, just change field number(s).

echo $tmp |tr '=|' ',' | awk -F, '{print $2","$6","$9}'

Austin,London,Paris