shell脚本中常用的技能
发布时间:2020-12-15 16:57:09 所属栏目:安全 来源:网络整理
导读:#/bin/bash threadCount=`cat count`;topic=`cat topic` #echo $topic #访问文件中每行的数据 for redis in $(cat redis.list); do echo $redis host=` echo $redis | awk -F ":" '{print $1}' ` port=` echo $redis | awk -F ":" '{print $2}' ` #echo $hos
#/bin/bash
threadCount=`cat count`;
topic=`cat topic`
#echo $topic
#访问文件中每行的数据
for redis in $(cat redis.list); do
echo $redis
host=`echo $redis | awk -F ":" '{print $1}'`
port=`echo $redis | awk -F ":" '{print $2}'`
#echo $host
#echo $port
#shell for循环
#for i in {1..50}; do
for (( index=0; index<$threadCount; index++ )); do
queueName=hehe-haha-$topic-2.2.2.223-$index
queueName2=hehe-haha-$topic-2.2.2.223-$index
#echo $queueName
result=`redis-cli -h $host -p $port zcard $queueName`
#echo $result
# shell if判断
if [ "$result" != "0" ]; then
echo "redis: $redis queue: $queueName length is $result "
zrangeResult=`redis-cli -h $host -p $port zrange $queueName 0 -1 withscores`
echo $zrangeResult
#shell中的字符串按照空格分割存到数组中
#array=(${zrangeResult})
# 数组的长度
#num=${#array[@]}
#for ((i=0; i<num;)); do
# value=${array[i]}
# i=$((i+1))
# score=${array[i]}
# i=$((i+1))
# redis-cli -h $host -p $port zadd $queueName2 $score $value
#done
fi
done
done
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |