# gawk profile, created Wed Jun 05 23:50:52 2017
# 首先,在shell下进入包含task.txt,nomatch.txt,sign.awk三个文件的目录。
# 然后,采用下面的shell命令格式化task.txt,方便awk使用逗号来处理nomatch.txt和生成的comm_task.txt
# sed 's/[\t]/,/g' task.txt > comm_task.txt
# 其次,确保sign.awk,nomatch.txt,comm_task.txt在同一个目录下,在shell下运行"awk --version",确保显示"GNU Awk",否则使用"gawk"替代"awk"来执行下面的命令(.
# awk -f sign.awk nomatch.txt comm_task.txt
# gawk -f sign.awk nomatch.txt comm_task.txt
# 此时你可以看到shell输出的结果类似为:
#1297,#Settings%Root,Settings_11503,关闭 NFC,王鹿丽
#1296,#Settings%Root,Settings_11002,关闭 移动 热 点,陈思璇
# BEGIN rule(s)
BEGIN {
FS = OFS = ","
}
# Rule(s)
NR == FNR {
a[$3] = $3
a2[$3] = $0
}
NR > FNR {
b[$2"_"$3"_"$4] = $2"_"$3"_"$4
b2[$2"_"$3"_"$4] = $5
}
# END rule(s)
END {
for (i in a) {
flag=0
split(a[i],arr,"_")
taskname= arr[1]
taskid= arr[2]
#print a[i],taskname,taskid
for (j in b) {
split(b[j],brr,"_")
btaskname= brr[1]
staskid= brr[2]
mtaskid= brr[3]
if(taskname == btaskname && staskid <= taskid && taskid <= mtaskid){
print a2[i],b2[j]
flag=1
break
}
}
if(flag==0)
print a2[i],"None"
}
}