今天写一个awk脚本运行时候出现报错:
1
2
3
4
|
awk
'BEGIN{
sum
= 0; lintCount=0;arrAll[
"0"
]=0;}{
for
(i=1;i<NF;i++){
if
(match($i,/^uri\[/)>0){ match($i,/\[(.*?)\]/,uri);}};
if
(match($i,/^logId\[/)>0){match($i,/\[(.*?)\]/,logId);}
split
(uri[1],arrURI,
"?"
);key=arrURI[0];print arrURI;
}' soundui.log.2017091710
|
1
|
awk
: cmd. line:4: (FILENAME=soundui.log.2017091810 FNR=94565) fatal: attempt to use array `arrAll'
in
a scalar context
|
这是想统计uri的个数的,但是说不支持关联数组。经过查看:
1
2
3
|
$
awk
--version
GNU Awk 3.1.3
Copyright (C) 1989, 1991-2003 Free Software Foundation.
|
发现是3.1.3,awk需要到4.1以后支持,所以只能升级了!
本文转自 梦朝思夕 51CTO博客,原文链接:http://blog.51cto.com/qiangmzsx/1966849