shell脚本中常用的技能

#/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

相关文章

用的openwrt路由器,家里宽带申请了动态公网ip,为了方便把2...
#!/bin/bashcommand1&command2&wait从Shell脚本并行...
1.先查出MAMP下面集成的PHP版本cd/Applications/MAMP/bin/ph...
1、先输入locale-a,查看一下现在已安装的语言2、若不存在如...
BashPerlTclsyntaxdiff1.进制数表示Languagebinaryoctalhexa...
正常安装了k8s后,使用kubect工具后接的命令不能直接tab补全...