开发者

decimal pattern matching

开发者 https://www.devze.com 2023-04-01 19:37 出处:网络
I have a big file and the lines patte开发者_JAVA百科rn is given below: MDQ[11:15],IO,MDQ[10:14],,,,MDQ[12:16],TPR_AAWD[11:15]

I have a big file and the lines patte开发者_JAVA百科rn is given below:

MDQ[11:15],IO,MDQ[10:14],,,,MDQ[12:16],TPR_AAWD[11:15]

I want to modify this file like given below:

MDQ[11],IO,MDQ[10],,,,MDQ[12],TPR_AAWD[11]
MDQ[12],IO,MDQ[11],,,,MDQ[13],TPR_AAWD[12]
MDQ[13],IO,MDQ[12],,,,MDQ[14],TPR_AAWD[13]
MDQ[14],IO,MDQ[13],,,,MDQ[15],TPR_AAWD[14]

How i can implement this in sed/awk/perl/csh/vim? Please help


awk -F '[][]' '{
    split($2, a, /:/)
    split($4, b, /:/)
    split($6, c, /:/)
    split($8, d, /:/)
    for (i=0; i < a[2]-a[1]; i++) {
        printf("%s[%d]%s[%d]%s[%d]%s[%d]\n",
            $1, a[1]+i,
            $3, b[1]+i,
            $5, c[1]+i,
            $7, d[1]+i)
    }
}'


Hope the below helps:

sed -e 's/:[0-9]*//g'
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号