• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            Prayer

            在一般中尋求卓越
            posts - 1256, comments - 190, trackbacks - 0, articles - 0
              C++博客 :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理

            顯示彩色字符的shell腳本

            Posted on 2009-08-27 20:06 Prayer 閱讀(265) 評論(0)  編輯 收藏 引用 所屬分類: Shell
            #!/bin/bash
            #"Colorizing" Scripts
            #First,define functions.
            function subColor()
            {
            Fg=$1
            Bg=$2
            SetColor="\E[""$Fg;$Bg""m"
            UseColor="\033[""$3""m"
            EndColor="\033[0m"
            Content=$e
            echo -en "$SetColor""$UseColor"$Content"$EndColor"
            }

            function ShowHelp()
            {
            echo "Error!"
            echo "Your parameters were $a,$b,$c,they are unexpected parameters."
            echo "Show help file or continue?(h|c)"
            read Choice
            case $Choice in
                h|H)
                    echo "This is a script for coloring characters and strings."
                    echo "There are four parameters.Parameters are seperated by spacebars."
                    echo "The frst parameter is a number ranged from 1 to 10,represents the foreground color."
                    echo "The second parameter is  a number ranged from 1 to 10,represents the background color."
                    Color 1 8 2 "1    red";echo
                    Color 2 8 2 "2    green";echo
                    Color 3 8 2 "3    yellow";echo
                    Color 4 8 2 "4    blue";echo
                    Color 5 8 2 "5    magenta";echo
                    Color 6 8 2 "6    cyan";echo
                    Color 7 8 2 "7    gray";echo
                    Color 8 9 2 "8    white";echo
                    Color 9 8 2 "9    white";echo
                    Color 10 9 2 "10   black";echo
                    echo "The third parameter is a number ranged from 1 to 9,represents the style of the characters."
                    Color 10 8 1 "1    lighter,and bold";echo
                    Color 9 8 4 "4    draw a line under the string.";echo
                    Color 9 8 5 "5    coruscate the string.";echo
                    Color 9 8 7 "7    swap the foreground color and the background color";echo
                    Color 9 8 9 "9    draw a deleting line";echo
                    echo "The fourth parameter is the content you wanna clolor,a string."
                    echo "Thanks for using this script ! "
            echo "Script halted."
            exit 1
                    ;;
                c|C)
                    echo "script halted."
                    exit 1
                    ;;
                *)
                    ShowHelp
            esac
               
            }

            function ParaCheck()
            {
            if [ $a -le 0 ] || [ $b -le 0 ] || [ $c -le 0 ] || [ $a -gt 10 ] || [ $b -gt 10 ] || [ $c -gt 9 ]
            then
                ShowHelp
            else
                if [ $a -eq 10 ]
                then
                    a=30
                else
                    a=30+$a
                fi
                if [ $b -eq 10 ]
                then
                    b=40
                else
                    b=40+$b
                fi
            fi
            }

            function GenString()
            {
                e=""
                declare -i f=1

                for d in $@
                do
                    if [ $f -eq 1 ] || [ $f -eq 2 ] || [ $f -eq 3 ]
                    then
                        e=$e
                    elif [ $f -eq 4 ]
                    then
                        e=$d
                    else
                        e="$e $d"
                    fi
                    
                    let f=$f+1
                done

            }

            function Color()
            {
            declare -i a=$1
            declare -i b=$2
            declare -i c=$3
            ParaCheck
            GenString $@
            subColor $a $b $c $e
            }
            #Here is where the script begins.
            Color $@



            本文來自ChinaUnix博客,如果查看原文請點(diǎn):http://blog.chinaunix.net/u1/53398/showart_419411.html
            热re99久久6国产精品免费| 久久亚洲国产午夜精品理论片| 性做久久久久久久久久久| 国产精品久久新婚兰兰| 99久久99久久精品免费看蜜桃 | 久久精品国产亚洲7777| 国内精品久久久久影院亚洲| 亚洲AV乱码久久精品蜜桃| 国产精品欧美亚洲韩国日本久久| 久久久久国产一区二区三区| 久久亚洲私人国产精品| 久久夜色撩人精品国产| 国产精品久久久久…| 亚洲乱码中文字幕久久孕妇黑人 | 久久亚洲sm情趣捆绑调教| 久久er热视频在这里精品| 亚洲国产美女精品久久久久∴| 国产巨作麻豆欧美亚洲综合久久| 蜜臀久久99精品久久久久久小说| 久久久久久国产精品免费免费 | 无码八A片人妻少妇久久| 女人香蕉久久**毛片精品| 热re99久久6国产精品免费| 欧美亚洲国产精品久久高清| 亚洲第一永久AV网站久久精品男人的天堂AV| 欧洲成人午夜精品无码区久久| 国产精品久久久久久久人人看| 久久久久亚洲AV成人网人人软件| 久久香蕉综合色一综合色88| 99久久精品毛片免费播放| 国产精品久久自在自线观看| 久久久久亚洲AV无码网站| 欧美噜噜久久久XXX| 亚洲日韩中文无码久久| 99久久国产宗和精品1上映| 狠狠色婷婷久久一区二区| 一本一道久久综合狠狠老| 人妻久久久一区二区三区| 久久99亚洲网美利坚合众国| 99久久久国产精品免费无卡顿| 精品久久久久久无码中文字幕一区|