amm@srv:~$ docker run -i --rm --net host redis sh -c "redis-cli -h 192.168.100.79 -p 7000 cluster nodes"
97a7d125e815f2bb0f219dfdec1943924473af56 192.168.101.90:7002 slave 4bb9aae34f4336f30117ef5901b68c94cd1d559b 0 1553869936402 6 connected
08a7ff2732079bc7b113726352101e5302a1f5d8 192.168.101.30:7001 master - 0 1553869932394 2 connected 10923-16383
d04349ce3e46ed74e6d4e16c2911d7e33865dc55 192.168.101.79:7000 myself,master - 0 0 4 connected 5461-10922
3145cb441cc7160bec3e34b8f1af8e2d5c7006cf 192.168.101.30:7002 slave d04349ce3e46ed74e6d4e16c2911d7e33865dc55 0 1553869934398 4 connected
4bb9aae34f4336f30117ef5901b68c94cd1d559b 192.168.101.30:7000 master - 0 1553869933395 1 connected 0-5460
0ba123ae6b4680f7682ecd794ba86130a3da66b4 192.168.101.90:7001 slave 08a7ff2732079bc7b113726352101e5302a1f5d8 0 1553869935399 5 connected
amm@srv:~$ docker run -i --rm --net host redis sh -c "redis-cli -h 192.168.100.79 -p 7000 cluster nodes | grep master"
08a7ff2732079bc7b113726352101e5302a1f5d8 192.168.101.30:7001 master - 0 1553870133883 2 connected 10923-16383
d04349ce3e46ed74e6d4e16c2911d7e33865dc55 192.168.101.79:7000 myself,master - 0 0 4 connected 5461-10922
4bb9aae34f4336f30117ef5901b68c94cd1d559b 192.168.101.30:7000 master - 0 1553870136888 1 connected 0-5460
amm@srv:~$ docker run -i --rm --net host redis sh -c "redis-cli -h 192.168.100.79 -p 7000 cluster nodes | grep master | awk '{print $2}'"
08a7ff2732079bc7b113726352101e5302a1f5d8 192.168.101.30:7001 master - 0 1553870264228 2 connected 10923-16383
d04349ce3e46ed74e6d4e16c2911d7e33865dc55 192.168.101.79:7000 myself,master - 0 0 4 connected 5461-10922
4bb9aae34f4336f30117ef5901b68c94cd1d559b 192.168.101.30:7000 master - 0 1553870268244 1 connected 0-5460
amm@srv:~$ docker run -i --rm --net host redis sh -c "redis-cli -h 192.168.100.79 -p 7000 cluster nodes | grep master | awk -F'[ ,:]' '{print $2}'"
08a7ff2732079bc7b113726352101e5302a1f5d8 192.168.101.80:7001 master - 0 1553867240149 2 connected 10923-16383
d04349ce3e46ed74e6d4e16c2911d7e33865dc55 192.168.101.79:7000 myself,master - 0 0 4 connected 5461-10922
4bb9aae34f4336f30117ef5901b68c94cd1d559b 192.168.101.80:7000 master - 0 1553867239144 1 connected 0-5460
amm@srv:~$ docker run -i --rm --net host redis sh -c "redis-cli -h 192.168.100.79 -p 7000 cluster nodes | grep master | awk '{print $2}'"
08a7ff2732079bc7b113726352101e5302a1f5d8 192.168.101.80:7001 master - 0 1553866828243 2 connected 10923-16383
d04349ce3e46ed74e6d4e16c2911d7e33865dc55 192.168.101.79:7000 myself,master - 0 0 4 connected 5461-10922
4bb9aae34f4336f30117ef5901b68c94cd1d559b 192.168.101.80:7000 master - 0 1553866823223 1 connected 0-5460
amm@srv:~$ echo "08a7ff2732079bc7b113726352101e5302a1f5d8 192.168.101.79:7001 master - 0 1553254293379 2 connected 10923-16383" | awk '{ print $2 }'
192.168.101.79:7001
У меня к Вам просьба посмотрите на пример это то что вы имели ввиду?
https://dotnetfiddle.net/fHWZ9n