jsawk

How can I put integer as an argument in jq?

人盡茶涼 提交于 2021-02-16 16:14:30
问题 I have been trying to use jq to parse a json file returned from the aws cli, but I'm stuck with the problem of referencing an array using the index number. I need to do this because I want to export a text file describing the security groups in a specific format, including all the inbound and outbound rules. for (( i=1; i<=groupCount; i++ )) ; do echo $i echo $(echo "$input" | jq --arg i $i '.SecurityGroups[$i]') done This returns an error: 1 jq: error (at <stdin>:189): Cannot index array

How to use jsawk if every line is a json object ?

瘦欲@ 提交于 2019-12-13 04:47:10
问题 My server generated a json object for each request, so I dump that json object to a access.log file. In this case, each line of access.log is an json object. So How can I use jsawk to parse access.log ? Is there any option to switch on ? 回答1: A good work around, use awk to preprocess the access.log like this: $ awk 'BEGIN {print "[";} {print $0,",";} END {print "]";}' access.log > | jsawk "return this.sometag" 来源: https://stackoverflow.com/questions/27117843/how-to-use-jsawk-if-every-line-is