Answer the question
In order to leave comments, you need to log in
Using the GNU awk utility?
Good day, the task is to clear the cache from the rediscluster, but I can’t understand why the awk utility does not behave as I expect.
Here is the output of my command without using the awk utility:
[email protected]:~$ 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.79:7001 master - 0 1553254293379 2 connected 10923-16383
d04349ce3e46ed74e6d4e16c2911d7e33865dc55 192.168.101.79:7000 myself,master - 0 0 4 connected 5461-10922
4bb9aae34f4336f30117ef5901b68c94cd1d559b 192.168.101.79:7000 master - 0 1553254294381 1 connected 0-5460
[email protected]:~$ 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 $1 $2}'"
[email protected]:~$ 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 $0}'"
0
0
0
Answer the question
In order to leave comments, you need to log in
Well so you have a string and is divided into two
$ echo "08a7ff2732079bc7b113726352101e5302a1f5d8 192.168.101.79:7001 master - 0 1553254293379 2 connected 10923-16383" | awk -F: '{print $1 $2}'
08a7ff2732079bc7b113726352101e5302a1f5d8 192.168.101.797001 master - 0 1553254293379 2 connected 10923-16383
$ echo "08a7ff2732079bc7b113726352101e5302a1f5d8 192.168.101.79:7001 master - 0 1553254293379 2 connected 10923-16383" | awk -F: '{print $1}'
08a7ff2732079bc7b113726352101e5302a1f5d8 192.168.101.79
$ echo "08a7ff2732079bc7b113726352101e5302a1f5d8 192.168.101.79:7001 master - 0 1553254293379 2 connected 10923-16383" | awk -F: '{print $2}'
7001 master - 0 1553254293379 2 connected 10923-16383
$ echo "08a7ff2732079bc7b113726352101e5302a1f5d8 192.168.101.79:7001 master - 0 1553254293379 2 connected 10923-16383" | awk '{ print $2 }'
192.168.101.79:7001
$ echo "08a7ff2732079bc7b113726352101e5302a1f5d8 192.168.101.79:7001 master - 0 1553254293379 2 connected 10923-16383" | awk '{ print $2 }' | awk -F: '{print $1}'
192.168.101.79
$ echo "08a7ff2732079bc7b113726352101e5302a1f5d8 192.168.101.79:7001 master - 0 1553254293379 2 connected 10923-16383" | awk '{ print $2 }' | awk -F: '{print $2}'
7001
My first goal is to take IP and ports...
192.168.101.79 7001
192.168.101.79 7000
192.168.101.79 7000
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question