We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
详细信息: v2ctl输出中存在换行符\r\n,脚本中 gsub(/^"|link"$/, "", $2); 无法匹配到后面的link,导致输出 inbound:api->uplink" 而非 inbound:api->up 脚本中 else if (match($0, /^>$/) && f) { f = 0; print 0; } 无法匹配 >,在无数据的情况下没有输出0,导致 print_sum() 报错 numfmt: 无效的数字:“”
v2ctl
\r\n
gsub(/^"|link"$/, "", $2);
inbound:api->uplink"
inbound:api->up
else if (match($0, /^>$/) && f) { f = 0; print 0; }
>
0
print_sum()
numfmt: 无效的数字:“”
修正: 在匹配行末的正则表达式中插入\s?,表示“匹配存在的任意空白字符”,以匹配多种换行符或无换行符的情况
\s?
| awk '{ if (match($1, /name:/)) { - f=1; gsub(/^"|link"$/, "", $2); + f=1; gsub(/^"|link"\s?$/, "", $2); split($2, p, ">>>"); printf "%s:%s->%s\t", p[1],p[2],p[4]; } else if (match($1, /value:/) && f){ f = 0; printf "%.0f\n", $2; } - else if (match($0, /^>$/) && f) { f = 0; print 0; } + else if (match($0, /^>\s?$/) && f) { f = 0; print "0"; } }'
The text was updated successfully, but these errors were encountered:
No branches or pull requests
高级篇-->流量统计-->流量信息的处理中实例脚本的awk命令出错
详细信息:
v2ctl
输出中存在换行符\r\n
,脚本中gsub(/^"|link"$/, "", $2);
无法匹配到后面的link,导致输出inbound:api->uplink"
而非inbound:api->up
脚本中
else if (match($0, /^>$/) && f) { f = 0; print 0; }
无法匹配>
,在无数据的情况下没有输出0
,导致print_sum()
报错numfmt: 无效的数字:“”
修正:
在匹配行末的正则表达式中插入
\s?
,表示“匹配存在的任意空白字符”,以匹配多种换行符或无换行符的情况The text was updated successfully, but these errors were encountered: