• <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
            伊人久久大香线蕉综合5g| 免费久久人人爽人人爽av| 日韩亚洲国产综合久久久| 91久久精品电影| 久久无码av三级| 精品久久久无码人妻中文字幕豆芽| 久久久久精品国产亚洲AV无码 | 亚洲一级Av无码毛片久久精品| 亚洲国产精品久久久久网站| 久久精品国产福利国产秒| 丁香狠狠色婷婷久久综合| 精品久久久久久久无码| 精品久久无码中文字幕| 狠狠色婷婷综合天天久久丁香| www.久久热| 久久996热精品xxxx| 亚洲国产成人精品女人久久久 | 亚洲国产成人久久一区久久| 精品久久人人做人人爽综合| 伊人久久大香线蕉综合5g| 色妞色综合久久夜夜| 精品久久一区二区| 女同久久| 91精品国产9l久久久久| 精品久久久无码中文字幕| 亚洲欧美日韩精品久久亚洲区| 国内精品综合久久久40p| 久久免费小视频| 一级做a爰片久久毛片看看| 久久精品国产亚洲av麻豆色欲| 狠狠干狠狠久久| 香蕉99久久国产综合精品宅男自 | 久久久久久久91精品免费观看| 亚洲中文字幕久久精品无码APP | 老男人久久青草av高清| 国产精品视频久久久| 久久久久久久久久免免费精品 | 国产91久久综合| 亚洲狠狠婷婷综合久久久久| 久久国产视频网| 精品无码久久久久久尤物|