表达式中的char'''无效

时间:2011-06-29 10:02:57

标签: awk gawk

您好我有以下awk程序

问题是我不知道为什么它会在第3行抱怨 当我执行 awk -f make.awk info.txt

时,“ awk'表达式中的无效字符”

你们这些人在这方面比我更聪明吗? =)

#!/bin/bash
function labels2 () {
    awk '
    /[0-9]/{
    print substr($3,length($3)-11), $3
    }' $@ | /bin/sort -u  | awk '{print "BUILD: " NR, $2}'
}

function labels () {
    awk ' 
    /[0-9]/{
    BL[$3] = substr($3,length($3)-11)
    }
    END {
    asort(BL)
    for (i in BL) {
        print i, BL[i]
    }
    }' $@
}


labels $@
exit 0

for a in $@
do
    labels $@ | gawk '
    /BUILD:/ {
    BUILD[$2] = $3
    BUILDCNT ++
    next
    }
    /[0-9]/ {
    DATEd[$3] = $1
    TIMEd[$3] = $2
    MODULESd[$3] = $4
    CASESd[$3] = $5
    FAILEDd[$3] = $6
    COVERd[$3] = $7
    LOCd[$3] = $8
    }
    END {
    SUBSYSTEM=substr(FILENAME, 1, length(FILENAME)-7)
    LABEL= "\"" toupper(SUBSYSTEM) "\""
    print "{"
        print "subsystem: " LABEL ","
        print "    date: {"
        print "        label: " LABEL ","
        print "        data: ["
        for (i = 0 ; i <= BUILDCNT; i ++ ) {
            B=BUILD[i]
            if (DATEd[B]) { print "            [" i ", \"" DATEd[B] "\"]," }
        }
        print "        ]"
        print "    },"
    }
    ' - $a
done

1 个答案:

答案 0 :(得分:0)

这不是一个awk程序,而是一个bash脚本。要运行它,请执行

chmod +x yourscript

然后

./yourscript parameters