$ echo 119.84.100.68 | xargs -I{} echo "1:ips:2016-08-16:{}" | while read cmd ; do echo -e "*2\r\n\$5\r\nzcard\r\n\$${#cmd}\r\n$cmd\r\n" ; done | redis-cli -p 26379 --pipe
All data transferred. Waiting for the last reply...
Last reply received from server.
errors: 0, replies: 1
day=${day:-`date "+%Y-%m-%d"`}
key="1:ips:$day"
for h in hadoop-master{1..4} ; do
exists=$(redis-cli -h $h -p 6372 exists $key)
if [ $exists -gt 0 ] ; then
redis-cli -h $h -p 6372 zrange $key 0 -1 > activeresourceip$day.data
for h in hadoop-master{1..4} ; do
cat activeresourceip$day.data | while read ip ; do echo -e "zcard $key:$ip\r" ; done | redis-cli -h $h -p 6372
done
fi
done | awk '{s+=$1} END {print s}'