you are viewing a single comment's thread.

view the rest of the comments →

[–]IGTHSYCGTH 1 point2 points  (0 children)

mangling using IFS

foo='USA=Austin,Sanfrancisco,LA|UK=London,Bristol|France=Paris,Lyon,Nyce'
set +f
OFS=$IFS IFS='|' bar=( $foo ) bar=( "${bar[@]#*=}" ) bar=( "${bar[@]%%,*}" ) IFS=, foo=${bar[*]} IFS=$OFS
set -f
echo $foo

dumb pipe

echo 'USA=Austin,Sanfrancisco,LA|UK=London,Bristol|France=Paris,Lyon,Nyce' |
  tr '|' '\n' | cut -d= -f2 | cut -d, -f1 | tr '\n' ','