linux shell 编写屏幕产生颜色的脚本

效果图:在rhel5下显示
 
200905231243071771937.jpg650) this.width=650;" border=0>
 
 
代码:
 
#!/bin/sh
tput init
MYDATE=`date +%D`
#---------function
function colour ()
{
  case $1 in
    black_green)
       echo "^[[40;32m"
       ;;
    black_yellow)
       echo "^[[40;33m"
       ;;
    black_white)
       echo "^[[40;37m"
       ;;
    black_cyan)
       echo "^[[40;36m"
       ;;
    black_red)
       echo "^[[40;31m"
       ;;
   esac
  
}
function xy ()
{
  _R=$1
  _C=$2
  _TEXT=$3
  tput  cup $_R $_C
  echo -n $_TEXT
}
function center ()
{
 _STR=$1
 _ROW=$2
 LEN=`echo $_STR | wc -c`
 COLS=`tput cols`
 HOLD_COL=`expr $COLS - $LEN`
 NEW_COL=`expr $HOLD_COL / 2`
 tput cup $_ROW $NEW_COL
 echo -n $_STR
}
#--------function end
tput clear
colour black_yellow
xy 2 3 "USER:$LOGNAME"
colour black_cyan
center "ADD A NEW WARP DRIVE TO A START SHIP" 3
echo -e "\f\f"
center "---------------------------------"  4
colour black_yellow
xy 5 1 "---------------------------------" 
xy 7 1 "---------------------------------"
xy 21 1 "---------------------------------"
center "Star Date $MYDATE"       22
xy 23 1 "---------------------------------"
colour black_green
xy 6 6 "Initials:"
read INIT
xy 8 14
echo -n "Security Code No:       :"
read CODE
xy 10 14
echo -n "Ship's Serial NO:       :"
read SERIAL
xy 12 14
echo -n "Is it on the Port Side:"
read PORT
colour black_red
center "Save This Record [Y..N]"  18
read ANS
colour black_white
--------------------------
说明:colour 函数控制颜色,其中 ^[  为控制字符,产生的方式,按,松开后,按ESC
            xy 函数  定位
            center 函数  居中显示

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/70109/viewspace-689629/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/70109/viewspace-689629/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值