Printing a string value in awk results in error

后端 未结 1 737
滥情空心
滥情空心 2020-12-21 14:16
fatal: not enough arguments to satisfy format string
    `%s SPT=80\'
     ^ ran out for this one

This my code

for ((h = 1 ; h <         


        
相关标签:
1条回答
  • 2020-12-21 15:01

    The problem is a missing comma in the printf command for awk:

    awk -v i=h -v j=17 'FNR == 2 {printf "%s ", $j}' newiptables.log
                                              ^
                                              |== This is needed
    

    Quoting from the manual:

    A simple printf statement looks like this:

     printf format, item1, item2, ...
    
    0 讨论(0)
提交回复
热议问题