How do I split a string on a delimiter in Bash?

后端 未结 30 1998
萌比男神i
萌比男神i 2020-11-21 04:58

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

30条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-21 05:28

    IN="bla@some.com;john@home.com"
    IFS=';'
    read -a IN_arr <<< "${IN}"
    for entry in "${IN_arr[@]}"
    do
        echo $entry
    done
    

    Output

    bla@some.com
    john@home.com
    

    System : Ubuntu 12.04.1

提交回复
热议问题