we have the following file
cat /tmp/hive.conf
"hive-exec-log4j2" : {
"tag" : "TOPOLOGY_RESOLVED",
"version" : 2
},
"hive-interactive-env" : {
"tag" : "TOPOLOGY_RESOLVED",
"version" : 2
},
"hive-interactive-site" : {
"tag" : "TOPOLOGY_RESOLVED",
"version" : 2
},
"hive-log4j" : {
"tag" : "TOPOLOGY_RESOLVED",
"version" : 2
},
"hive-log4j2" : {
"tag" : "TOPOLOGY_RESOLVED",
"version" : 2
},
we want to capture the line after match the "hive-log4j" from file
so we get that:
cat /tmp/hive.conf | awk '/"hive-log4j"/{getline; print}'
"tag" : "TOPOLOGY_RESOLVED",
now we want to do the same with awk and export the variable as the following
val="hive-log4j"
cat /tmp/hive.conf | awk -v var=$val '/"var"/{getline; print}'
but no output
what is wrong with my syntax?
jq
. It looks as if it's been proprocessed and broken in the processing. – Kusalananda Aug 05 '18 at 14:28jq
command to parse it. – Kusalananda Aug 05 '18 at 14:41sed -n '/hive-log4j/N;s/.*\n//p'
– mikeserv Aug 05 '18 at 15:02