awk opposite of split

后端 未结 5 969
执笔经年
执笔经年 2021-01-12 04:03

what would be an opposite of split() in awk? Imagine I have array containig characters/integers.

What I\'ve tried:

color =          


        
5条回答
  •  醉酒成梦
    2021-01-12 04:44

    Here is a way with POSIX Awk:

    br = "red,orange,yellow,green,blue"
    ch = split(br, de, ",")
    print "original: " br
    printf "joined: "
    for (ec in de) printf ec == ch ? de[ec] "\n" : de[ec] "-"
    

    Output:

    original: red,orange,yellow,green,blue
    joined: red-orange-yellow-green-blue
    

提交回复
热议问题