Artificial intelligent assistant

awk + how to count lines with apecific structure How do I use `awk` to count all lines adhering to the following structure: "any-string" : "any-string" For example "ssl.server.keystore.type" : "mapred-logsearch-conf" : { "hive.server2.thrift.sasl.qop" : "auth", "hive.merge.orcfile.stripe.level" : "true", "hive.orc.splits.include.file.footer" : "false", "hive.exec.compress.output" : "false", "hive.user.install.directory" : "/user/", "hive.prewarm.enabled" : "false", "hive.compactor.delta.num.threshold" : "10", "hive.orc.compute.splits.num.threads" : "10", "hive.vectorized.groupby.checkinterval" : "4096", "properties_attributes" : { }, would produce the output "9".

Since you ask an `awk` code, here is one:


awk '/"[^"]*"[[:space:]]*:[[:space:]]*"[^"]*"/ { n++ } END { print n }'


But `grep` is more appropriate for this:


grep -c '"[^"]*"[[:space:]]*:[[:space:]]*"[^"]*"'

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 0aadefb45394104662d4b963dbd16688