awk
次の構造に一致するすべての行を計算する方法:
"any-string" : "any-string"
例えば
"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" : { },
出力「9」を生成します。
ベストアンサー1
コードをリクエストしたため、awk
コードは次のようになります。
awk '/"[^"]*"[[:space:]]*:[[:space:]]*"[^"]*"/ { n++ } END { print n }'
しかし、grep
より適切なものは次のとおりです。
grep -c '"[^"]*"[[:space:]]*:[[:space:]]*"[^"]*"'