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?