I have some JSON data:
"Item1": {
"foo": null,
"version": "bar",
"result": null,
},
"Item2": {
"foo": null,
"version": "bar",
"result": null,
},
"Item3": {
"foo": null,
"version": "bar",
"result": null,
},
With awk
I'm able to filter strings:
$ awk '/version/' /tmp/json
"version": "bar",
"version": "bar",
"version": "bar",
I'm trying to count the number of lines and get the following result without piping, pure awk.
$ awk '/version/' /tmp/json | wc -l
3
Examples online show how to use END
and NR
but this doesn't produce the results I'm looking for:
$ awk '/version/{print NR}' /tmp/json
3
8
13
or
$ awk 'END/version/{print NR}' /tmp/json
awk: line 1: syntax error at or near /version/
jq
for this?