如何在Bash中的分隔符上拆分字符串?
IN="bla@some.com;john@home.com"
;
ADDR1="bla@some.com"ADDR2="john@home.com"
ADDR1
ADDR2
#!/usr/bin/env bashIN="bla@some.com;john@home.com"mails=$(echo $IN | tr ";" "\n")for addr in $mailsdo echo "> [$addr]"done
> [bla@some.com]> [john@home.com]
;
IFS
IFS
IFS
IN="bla@some.com;john@home.com"OIFS=$IFS IFS=';'mails2=$INfor x in $mails2do echo "> [$x]"doneIFS=$OIFS
mails2=($IN)
$IN
慕侠2389804
斯蒂芬大帝
交互式爱情