<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    java要多思考下

    成長^_^

       ::  :: 新隨筆 ::  ::  :: 管理 ::
      33 隨筆 :: 0 文章 :: 19 評論 :: 0 Trackbacks
    取腳本運行參數(shù): $0 $1 $2 ...
    取腳本運行參數(shù)個數(shù): $#
    取腳本運行的所有參數(shù):$*
    判斷字符串相等:if [[ "$1" = "-cmd" ]]; then command=$2 fi ([后有空格,]前也有空格)
    變量命名:string1="/usr/local/redis/bin/redis-cli"
    取變量值:$string1
    命令調(diào)用:`export abc="abc"`
    字符串命令調(diào)用:result=`eval $string`
    將命令調(diào)用值賦給數(shù)組:results=(`eval $string`)
    取數(shù)組長度:${#results[@]}
    取數(shù)組值:${results[i]}
    取運行參數(shù)數(shù)組值:${!i}
    調(diào)用外部腳本:. xxxx.sh

    附:redis數(shù)據(jù)批量操作腳本
    #!/bin/bash
    command="keys '*'"
    action="noaction"
    redis_cli="/usr/local/redis/bin/redis-cli"

    if [[ "$1" = "-cmd" ]]; then
        command=$2
    fi

    if [[  "$3" = "-act"  ]]; then
        action=$4
    fi

    #collect the command result to an array named results
    echo "=====> do command: $command"
    exec_command="$redis_cli $command"
    results=(`eval $exec_command`)

    if [[ ${#results[@]} = 0 ]];then
        exit 1
    fi

    for (( i = 0; i < ${#results[@]}; i++ )); do
        case $action in
            del)
                doaction="$redis_cli del ${results[i]}"
                ;;
            ttl)
                doaction="$redis_cli ttl ${results[i]}"
                ;;
            expire)
                doaction="$redis_cli expire ${results[i]} 60"
                ;;
            *)
                doaction="echo \"${results[i]}\""
                ;;
        esac
        
        actionResult=`eval $doaction`
        echo "=====> do action: $doaction ==> result: $actionResult"
    done

    調(diào)用形式:
    ./xxxx.sh
    ./xxxx.sh -cmd 'keys aa*'
    ./xxxx.sh -cmd 'keys aa*' -act del
    ./xxxx.sh -cmd 'keys aa*' -act expire
    ./xxxx.sh -cmd 'keys aa*' -act ttl

     
    posted on 2013-02-22 17:50 java要多思考下 閱讀(1790) 評論(0)  編輯  收藏 所屬分類: 系統(tǒng)運維
    主站蜘蛛池模板: 亚洲区小说区图片区QVOD| 久久久久亚洲AV综合波多野结衣| 亚洲国产日韩一区高清在线 | 久久久高清日本道免费观看| 在线观看亚洲成人| 在线毛片片免费观看| 亚洲精品二区国产综合野狼| 久久成人免费电影| 亚洲欧洲国产视频| 成年大片免费视频| 免费的黄网站男人的天堂 | 亚洲午夜国产精品无码| 在线观看特色大片免费网站| 久久久影院亚洲精品| 7723日本高清完整版免费| 久久精品国产亚洲AV久| 国产v片免费播放| 国产做国产爱免费视频| 亚洲黄色一级毛片| 四虎免费在线观看| 中文字幕在线免费观看视频| 亚洲专区在线视频| 暖暖免费高清日本中文| a级毛片毛片免费观看久潮| 亚洲精品福利在线观看| 国产成人免费永久播放视频平台| 一级毛片a女人刺激视频免费| 亚洲av无码专区在线播放 | 亚洲午夜久久久影院| 五月婷婷在线免费观看| 亚洲成a人无码亚洲成www牛牛| 亚洲男人天堂2020| 免费能直接在线观看黄的视频 | 久久亚洲精品无码aⅴ大香| 天天干在线免费视频| 华人在线精品免费观看| 亚洲av无码专区在线电影天堂| 亚洲精品无码久久久久去q | 成人免费视频77777| 一级**爱片免费视频| 亚洲人成在线精品|