Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/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中打印字符串值会导致错误_Awk - Fatal编程技术网

在awk中打印字符串值会导致错误

在awk中打印字符串值会导致错误,awk,Awk,这是我的密码 fatal: not enough arguments to satisfy format string `%s SPT=80' ^ ran out for this one 问题是awk的printf命令中缺少逗号: Dec 26 09:17:51 localhost kernel: IN=eth0 OUT= MAC=00:10:c6:a8:da:68:00:90:7f:9c:50:5a:08:00 SRC=198.252.206.16 DST=10.128.

这是我的密码

fatal: not enough arguments to satisfy format string
    `%s SPT=80'
     ^ ran out for this one

问题是
awk
printf
命令中缺少逗号:

Dec 26 09:17:51 localhost kernel: IN=eth0 OUT= MAC=00:10:c6:a8:da:68:00:90:7f:9c:50:5a:08:00 SRC=198.252.206.16 DST=10.128.1.225 LEN=313 TOS=0x00 PREC=0x00 TTL=64 ID=59334 PROTO=TCP SPT=80 DPT=56506 WINDOW=46535 RES=0x00 ACK PSH URGP=0 
Dec 26 09:17:52 localhost kernel: IN=eth0 OUT= MAC=00:10:c6:a8:da:68:00:90:7f:9c:50:5a:08:00 SRC=198.252.206.16 DST=10.128.1.225 LEN=1440 TOS=0x00 PREC=0x00 TTL=64 ID=47303 PROTO=TCP SPT=80 DPT=56506 WINDOW=46535 RES=0x00 ACK URGP=0 
Dec 26 09:17:52 localhost kernel: IN=eth0 OUT= MAC=00:10:c6:a8:da:68:00:90:7f:9c:50:5a:08:00 SRC=198.252.206.16 DST=10.128.1.225 LEN=1440 TOS=0x00 PREC=0x00 TTL=64 ID=47559 PROTO=TCP SPT=80 DPT=56506 WINDOW=46535 RES=0x00 ACK URGP=0 
引述:

一个简单的
printf
语句如下所示:

awk -v i=h -v j=17 'FNR == 2 {printf "%s ", $j}' newiptables.log
                                          ^
                                          |== This is needed
密切相关的问题:。不是完全重复,而是相同的数据流。
awk -v i=h -v j=17 'FNR == 2 {printf "%s ", $j}' newiptables.log
                                          ^
                                          |== This is needed
 printf format, item1, item2, ...