• <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++博客 :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

            顯示彩色字符的shell腳本

            Posted on 2009-08-27 20:06 Prayer 閱讀(267) 評論(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博客,如果查看原文請點:http://blog.chinaunix.net/u1/53398/showart_419411.html
            亚洲国产成人精品无码久久久久久综合 | 国产欧美久久久精品| 久久国产精品成人片免费| 久久精品国产亚洲av麻豆图片| 伊人久久大香线蕉综合5g| 久久精品蜜芽亚洲国产AV| 亚洲午夜精品久久久久久人妖| 亚洲精品国产自在久久| 无码人妻精品一区二区三区久久久 | 一本色道久久综合狠狠躁篇| 色婷婷综合久久久中文字幕| 国产精品九九久久精品女同亚洲欧美日韩综合区 | 久久久噜噜噜久久中文字幕色伊伊| 77777亚洲午夜久久多喷| 曰曰摸天天摸人人看久久久| 亚洲色欲久久久综合网| 久久涩综合| 久久国产精品久久久| 久久人妻少妇嫩草AV蜜桃| 国产精品嫩草影院久久| 伊人久久大香线蕉av不卡| 久久97久久97精品免视看| 欧洲人妻丰满av无码久久不卡| 久久精品亚洲福利| 99国内精品久久久久久久 | 久久男人中文字幕资源站| 99久久精品费精品国产 | 久久精品国产亚洲Aⅴ香蕉| 国内精品久久九九国产精品| 久久久久久国产精品无码超碰| 久久久久国色AV免费观看| 精品欧美一区二区三区久久久| 99国产欧美久久久精品蜜芽| 欧美精品久久久久久久自慰| 亚洲中文精品久久久久久不卡| 一本色道久久综合| 久久午夜夜伦鲁鲁片免费无码影视| 久久久精品久久久久久| 四虎影视久久久免费观看| 欧美久久久久久| 无码超乳爆乳中文字幕久久 |