Split in Shell Script

透過linux上的tr功能,寫shell也可以輕鬆的拆字喔∼

#!/usr/bin/env bash    
IN="xxx@ooo.com,yyy@ooo.com"    
arr=$(echo $IN | tr "," "\n")    
for x in $arr  do
      echo "> [$x]"  
done
Result:  [xxx@ooo.com]  [yyy@ooo.com]