I have the following output from the following command
zookeeper-shell.sh 19.2.6.4 get /brokers/ids/1010
output is
Connecting to 19.2.6.4
WATCHER::
WatchedEvent state:SyncConnected type:None path:null
{"listener_security_protocol_map":{"PLAINTEXT":"PLAINTEXT"},"endpoints":["PLAINTEXT://kafka1.lulu.com:6667"],"rack":"/default-rack","jmx_port":9997,"port":6667,"host":"kafka1.lulu.com","version":4,"timestamp":"1630507307906"}
The main target is to capture the machine name kafka1 – from above output
So I successes to do the following long command syntax
zookeeper-shell.sh 119.2.6.4 get /brokers/ids/1010 | sed s'/\/\// /g' | sed s'/:/ /g' | sed s'/,/ /g' | sed s'/"/ /g' | sed s'/\./ /g'| awk '{for (i=1;i<=NF;i++) print $i}' | grep -i kafka | sort | uniq
and the results is: ( as expected results )
kafka1
the case is that I feel bad with my approach , its too long and not so elegant
can we get suggestion ( with awk/sed/perl one liner ) , that are much better from my syntax?