I have this string stored in a variable:
IN=\"bla@some.com;john@home.com\"
Now I would like to split the strings by ;
delimite
Here is a clean 3-liner:
in="foo@bar;bizz@buzz;fizz@buzz;buzz@woof"
IFS=';' list=($in)
for item in "${list[@]}"; do echo $item; done
where IFS
delimit words based on the separator and ()
is used to create an array. Then [@]
is used to return each item as a separate word.
If you've any code after that, you also need to restore $IFS
, e.g. unset IFS
.