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

后端 未结 30 2001
萌比男神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:44

    I think AWK is the best and efficient command to resolve your problem. AWK is included by default in almost every Linux distribution.

    echo "bla@some.com;john@home.com" | awk -F';' '{print $1,$2}'
    

    will give

    bla@some.com john@home.com
    

    Of course your can store each email address by redefining the awk print field.

提交回复
热议问题