Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
打印数值<;awk中的NF?_Awk - Fatal编程技术网

打印数值<;awk中的NF?

打印数值<;awk中的NF?,awk,Awk,我使用pgbench运行了一系列测试,记录了结果: run-params: 1 1 1 transaction type: SELECT only scaling factor: 1 query mode: simple number of clients: 1 number of threads: 1 duration: 90 s number of transactions actually processed: 280465 tps = 3116.254233 (including con

我使用pgbench运行了一系列测试,记录了结果:

run-params: 1 1 1
transaction type: SELECT only
scaling factor: 1
query mode: simple
number of clients: 1
number of threads: 1
duration: 90 s
number of transactions actually processed: 280465
tps = 3116.254233 (including connections establishing)
tps = 3116.936248 (excluding connections establishing)

run-params: 1 1 2
transaction type: SELECT only
scaling factor: 1
query mode: simple
number of clients: 1
number of threads: 1
duration: 90 s
number of transactions actually processed: 505943
tps = 5621.570463 (including connections establishing)
tps = 5622.811538 (excluding connections establishing)

run-params: 10000 10 3
transaction type: SELECT only
scaling factor: 10000
query mode: simple
number of clients: 10
number of threads: 1
duration: 90 s
number of transactions actually processed: 10
tps = 0.012268 (including connections establishing)
tps = 0.012270 (excluding connections establishing)
我想提取用于绘图的值。同时努力学习AWK。以下是我的AWK计划:

/run-params/      { scaling = $2 ; clients = $3 ; attempt = $4 }
/^tps.*excluding/ { print $scaling "," $clients "," $attempt "," $3 }
当我运行它时,我得到以下输出:

$ awk -f b.awk -- b.log 
tps,tps,tps,3116.936248
tps,tps,=,5622.811538
,,0.012270,0.012270
这不是我想要的

我知道当
scaling=1
时,1引用字段1,在本例中,字段1恰好是tps。当scaling=10000时,因为行上没有10000个字段,所以返回null。我确实尝试过使用
“$2
”分配缩放和朋友,但没有效果


如何在后续操作块中使用/报告数值?

只需将
$
放在
缩放
前面,等等。也就是说,
缩放
是变量引用,
$scaling
是字段引用。

只需将
$
放在
缩放
前面,等等。也就是说,
scaling
是一个变量引用,
$scaling
是一个字段引用。

awk不使用
$
引用变量,如果您将
$scaling“、“$clients”、“$trunt
更改为
scaling”、“clients”、“trunt
它应该可以正常工作。下面是代码:
awk'/run params/{scaling=$2;clients=$3;trunt=$4}/^tps.*不包括/{print scaling,clients,trunt,$3}'OFS=“,”文件
awk不引用带有
$
的变量,如果您将
$scaling“,“$clients”,“$trunt
更改为
scaling”,“clients”,”尝试
awk'/run params/{scaling=$2;clients=$3;trunt=$4}/^tps.*不包括/{print scaling,clients,trunt,$3}of s=“,”文件你没有看到上面雷神的评论吗,就像5分钟前一样?@Steve这本应该是一个更好的答案。而且,没有,我跳过了评论来检查答案。我同意,这本应该是一个答案。但是你应该在发布之前认真阅读问题、评论和答案。这也很有礼貌。@Steve我简要浏览了一下评论,检查没有什么看起来像是正确的答案,并提交了一份。你没有看到上面雷神的评论吗,比如5分钟前?@Steve,作为一个答案会更好。而且,没有,我跳过了评论来检查答案。我同意,这应该是一个答案。但你应该在发帖前认真阅读问题、评论和答案史蒂夫:我简短地浏览了一下评论,检查没有什么看起来像是正确的答案,然后提交了一份。