How do I split a string on a delimiter in Bash?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have this string stored in a variable: IN="bla@some.com;john@home.com" Now I would like to split the strings by ; delimiter so that I have: ADDR1="bla@some.com" ADDR2="john@home.com" I don't necessarily need the ADDR1 and ADDR2 variables. If they are elements of an array that's even better. After suggestions from the answers below, I ended up with the following which is what I was after: #!/usr/bin/env bash IN="bla@some.com;john@home.com" mails=$(echo $IN | tr ";" "\n") for addr in $mails do echo "> [$addr]" done Output: > [bla@some.com] >