shell脚本学习总结04--终端信息的获取和设置
tput
tput 命令将通过 terminfo 数据库对您的终端会话进行初始化和操作。通过使用 tput,您可以更改几项终端功能,如移动或更改光标、更改文本属性,以及清除终端屏幕的特定区域。
文本属性
tput Color Capabilities: tput setab [-] – Set a background color using ANSI escape
tput setb [-] – Set a background color
tput setaf [-] – Set a foreground color using ANSI escape
tput setf [-] – Set a foreground color Color Code for tput: – Black
– Red
– Green
– Yellow
– Blue
– Magenta
– Cyan
– White tput Text Mode Capabilities: tput bold – Set bold mode
tput dim – turn on half-bright mode
tput smul – begin underline mode
tput rmul – exit underline mode
tput rev – Turn on reverse mode
tput smso – Enter standout mode (bold on rxvt)
tput rmso – Exit standout mode
tput sgr0 – Turn off all attributes
例一,使输出的字符串有颜色,底色,加粗
#!/bin/bash printf $(tput setaf ; tput bold)'color show\n\n'$(tput sgr0) for((i=; i<=; i++)); do
echo $(tput setaf $i)"show me the money"$(tput sgr0)
done printf '\n'$(tput setaf ; tput setab ; tput bold)'background color show'$(tput sgr0)'\n\n' for((i=,j=; i<=; i++,j--)); do
echo $(tput setaf $i; tput setab $j; tput bold)"show me the money"$(tput sgr0)
done exit
运行结果:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPsAAAF2CAIAAAAnSXlDAAAgAElEQVR4nO2dPYgdR7bHK3HiwEagwAZZQg4klpsYZeNgEgnGgRGLTYNY2LEWBolJhEHoA8yFmwhrjGElZQMj0CKE4SoQCMEiLqwWVoECTbJ7E79YjiZWPC+or1Offbp7pkvT/f9RvJ2p7q46H/+qPl0j84Tw+Hb7D8X2t/418EFw/RUyBAAAAAAAAADg8Pl2G5+eIIE9P/rwNSIPUhhmHhnFn2G71CcfplVczlx/9er6mdTV66/+MFfpz0I4ayFYE+baq+tnTIS8INHnt7e3DyaA3x7QOO2nf3Vd/28yqo3H/AC1dTBWlTiPzyle58/+GrMr3n3m+iv6rBDuPM4uK1fEkVB8/jz+zPVX8oL+34PgQFw64+9XXTk4xcfFY/bL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5v2hgPvK7LDHp5LBCXYLfTTgQPd4Jj3v8T56guwLfRx4rzy/J6uAuurTfjbNKxVqpmLy+jDz+hLg7/H0Xlok8/xtMS/To2wdH1c80yq7/Yz8JCp2TqOD4uzR8yrSIUTyhIEOrrTEDLdzvFDp35YzVxXhC6TBzhV4Hb6TUv62mZfnUSKSjq10ddC5GVY12hQAOPKMvoD/f01LqEmrwTBHAAAAAElFTkSuQmCC" alt="" />
例2,输出格式控制函数
#!/bin/bash # $ str print string
# $ color - 设置颜色
# $ bgcolor - 设置背景颜色
# $ bold - 设置粗体
# $ underline - 设置下划线 function format_output(){
str=$
color=$
bgcolor=$
bold=$
underline=$
normal=$(tput sgr0) case "$color" in
|||||||)
setcolor=$(tput setaf $color;) ;;
*)
setcolor="" ;;
esac case "$bgcolor" in
|||||||)
|||||||)
setbgcolor=$(tput setab $bgcolor;) ;;
*)
setbgcolor="" ;;
esac if [ "$bold" = "" ]; then
setbold=$(tput bold;)
else
setbold=""
fi if [ "$underline" = "" ]; then
setunderline=$(tput smul;)
else
setunderline=""
fi printf "$setcolor$setbgcolor$setbold$setunderline$str$normal\n"
} format_output "Yesterday Once More" exit
运行结果:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAP8AAAAnCAIAAABPBwnfAAAFMklEQVR4nO1bPY4qMQzmBHuCrUdCnIAT0EyFxEmm3JNMzTG2mO5VVNtvicQBoOYVk2Rsx3EyYYYhrD9Z2kd+HNv54pigt1qxqNuzQVvzIxQLo+l0hxQKhUKhUCgUCoVC8dqoW/3aqkjA8A71+nzpH2QSzCyG/VWyS8/Ea1qVg6rpuqYK9Tbd2fXCf69W6Fx458P1dU3lokUCBue3bTtNMOuJ9OQv3zX2bzCqo3W+IM+mt2qJ936J/XYvh4+cXXxz1XRw7mqF10HZtz8dRbBffu+vmq7vsH+nwMMuOZunDM087OeJ5PIon0aHVptuufm0F7UzARoOhhs5Ffu9OePoAq+NroO6esXQMxyOcILp53RNcCpWwlprU/741B/2qHc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GLsT0w/NKmgsnJM7me1+dvPzAVfr/2aQRjPpsaQiHX/x+S5P03405uR+5PiDKR4RNnvUvsQGtDi7yhtMYPt3tjnVFiPsprlXaH1qHulBez3vvDRXcz5lSBSQ0vs9+t+1JIQjTz2p9f9zEKiVcUDURYKIoR/AxomMRM9Mnlj4D4FNbNvI/JL1KBhH+riNYx8Fgy89yN7dr9r5DhlHl/YBKORaoz/i43VEHrzicc5bFXxGLPrbyfsXaeSLMVj8QguJ7HXKpWYFA++PFBRick7sH/x/KFSrhSPxSOoUq4oFIXjLso74j/PME4o4BISlwAAAABJRU5ErkJggg==" alt="" />
光标属性
tput clear # 清屏 tput sc # 保存当前光标位置 tput cup # 将光标移动到 row col tput civis # 光标不可见 tput cnorm # 光标可见 tput rc # 显示输出
例一
#!/bin/bash
# clear the screen
tput clear
# Move cursor to screen location X,Y (top left is ,)
tput cup
# Set a foreground colour using ANSI escape
tput setaf
echo "XYX Corp LTD."
tput sgr0
tput cup
# Set reverse video mode
tput rev
echo "M A I N - M E N U"
tput sgr0
tput cup
echo "1. User Management"
tput cup
echo "2. Service Management"
tput cup
echo "3. Process Management"
tput cup
echo "4. Backup"
# Set bold mode
tput bold
tput cup
read -p "Enter your choice [1-4] " choice
tput clear
tput sgr0
tput rc
exit
运行结果:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAakAAAD0CAIAAACuKU6RAAAOWElEQVR4nO3du5GcygIGYBKRcZxxlMF15Y6rKgWgDKj15SgBeUSgKjkKAVcBKIWJQ9eYgekXr4FZdna+r07V0QINDUv/al6tqood6vZ0Op1ObX3o/3w6Ncd8iX6xYvl0bjT9lK/2ULeXpfslw412jk1p8qFu2zqc0K+sWKZui+te49iU61sdm/NR6P6/bJX9gWyjfTg2p+YYHNCFaz67HOeFR+LetYJ91W3btqWGcWyiqYe6DX8cnxsGXKYLqC5EyiF3U/YNB9N2Spsoxf3cahyifE4P5DmAugmHuj3Fuz+vwm3TtMsOzN1rBXtLQyuYXmjh3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0b4Frs++0rVyMGU0+7a935dud+q3MHO/7nG/b7K47OM+xi6J/v399St6y+Bj9Hd1f6Zmf4GHbSTfwKVcecs39rUK5ZZVqltmfa3y3kzwwGFkwmidhys8sd3B8rc8w5lzWX1T/Mk+WGplv5FZ9vycRPZBrniXjM1Nvlx4F95thlR+Cafnx4XsA56R7AMAAAAAAAAAAAAAAAAAgPfo/1Vq6SpmzNIZAAAAAElFTkSuQmCC" alt="" />
例2:
#/bin/bash
echo -n Count:
tput sc
count=
while true;do
if [ $count -lt ];then
let let count++
sleep
tput rc
tput ed
echo -n $count;
else exit o
fi
done
运行结果:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPkAAAAvCAIAAACuSvv1AAAEHElEQVR4nO2czZHcIBBGFQ1nB+GjMpidg2MgB8+moEi8N447Zcchp2EfNAgaNQ1IaFaDvleu2lqhn0Y8tbCA7a7v9+v7/ePP32/ff3Qx+mEch36xWZsxwGhF9lD+LmFhonS67Ay9vjbcAcxh9GBXZLQiAUx79MM4aFItptrCTeKv+rhRQ0/28c/MhDzv4MrmGGOh8e2ktJm22p/FaMNcLh4ziXC6x0Yruz0vhKCllti2C04ntEK3xfUvRXgQTssR2+lAZLsOqQ7N/DJCC0XJch2ABoDr4CzAdXAW4Do4C3D9SOBDyp68rOveN8fD2zF/X0/xMq6r7Co9k0RUh3VdaRMdLaJjSeG4kjCW5MqCsaTYwM4wDHUatK90nvWXN9r+jN7V4nMezPWuE6M67Pd1yXXbcu5XLi5+s9LGP7br6HVIZlXsgOEq9hZD/r6+feiUoUKVkqOjVaPaMm5q06LRKpIi180RUMvJB+S07jGY96zl+uKYMjn8V4Ix/rmmE/s1o7cjnk7sIHv0UHoSNlqbzsvTerxGU5Uyoooiv7rrR7V9joA2xrDprx/IVqXNSBtfKBVvhBXShrVbXi9DkeeCq+7ovY76gbMjGrO3s9JmpFWQgucSR24FxRoF01viUcUQJvbsE1UN1/lCJiN6nsmlXY7rsxelrodNH1yH9PcLEo+S3gHcLWQCzHs+Y+/paDs9Igv6fknEGi2iWNenme52SX5fHVWVvM4FytZc1pNsTLs+17lmXl+eo6Qd4o8J23tYXrq661vSulyjSq53xTd5dVS7ub5jXp+LvIbkpwSXus4YuboFFfk+9JV53SYFOSGmoTWq57o4Q7tiVPu5vrG/Hrxwp2efLRKiXuE6fWwKuu+LXcmD88hEtP4F/fUtrq/94CjXqJrrKqo6afTtUWGthr9Hj7UaeTUK75z7PftpSn5vLF+NkYgKazUa4ojtdCCut4OOJYEisFYjzVuO6wA0wNvt/naD6+AEwHVwFh6u/4brXfdP/AdeHbjugOttA9cdcL1t0q7TGRVmGEzZdLaVrJ/wuRq43jYJ14ORfDuI/oTAKrgeH3zmS+F628iuJ2doxcb5g+nadjDKn1YcX3+QWquRxRxBfK5OWArX20ZyfTFNKkSevyXPWEqtP6iQ1+W5ostSuN42W1xPZP2k6+LcvbTryWnPcB34JFyXug6p9RY7uz51dKR94DrwKe6vy6XPzOtJ4DrwSX1zDI0gffJkf907NPzzE8n1B8JaDT60EPo/goxSuN42OWNJ9AM7FU5cb0H/RIR2K7zz1h/IU9TlPoy8PI8vhettg3FTB1xvG7jugOttA9cdcL1t4LoDrrfNBa6Dk3C53S9wHZyByfVfcB00D1wHZwGug7MA18FZgOvgLFx+fl5un3AdNM9/xKJ9GEWKJNEAAAAASUVORK5CYII=" alt="" />
1.获取终端的行数和列数
# tput cols # tput lines
2. 移动光标
[root@IHS ~]# tput cup [root@IHS ~]#
stty
使输入的密码不在屏幕上显示
#/bin/bash
echo -e "Enter password:"
stty -echo
read passwd
stty echo
shell脚本学习总结04--终端信息的获取和设置的更多相关文章
- shell脚本学习之6小时搞定(1)
shell脚本学习之6小时搞定(1) 简介 Shell是一种脚本语言,那么,就必须有解释器来执行这些脚本. Unix/Linux上常见的Shell脚本解释器有bash.sh.csh.ksh等,习惯上把 ...
- 笔记——shell脚本学习指南
<shell脚本学习指南>机械工业出版 ISBN 987-7-111-25504-8 第2章 2.4 初级陷阱 1.当今的系统,对#!这一行的长度限制从63到1024个字符都有,尽量不要超 ...
- Shell 脚本学习资料搜集
Shell文档 ChinaUnix上大神“網中人”总结的Shell十三问,强烈推荐,这本书讲得比较精炼,而且都是一些Shell学习中容易把握不住的一些细节难点.每一问都写得非常精彩.ChinaUnix ...
- 学习笔记之Shell脚本学习指南 & sed与awk & 正则表达式
正则表达式_百度百科 http://baike.baidu.com/link?url=ybgDrN2WQQKN64_gu-diCqdeDqL8LQ-jiQ-ftzzPaNUa9CmgBRDNnyx50 ...
- 转 shell脚本学习指南
shell脚本学习指南 以下八点不敢说就能成为你shell脚本学习指南de全部,至少可以让你编写出可靠的shell脚本. 1. 指定bashshell 脚本的第一行,#!之后应该是什么?如果拿这个问题 ...
- Shell脚本学习 - 运算符
继续shell脚本学习.上一篇是基本数据类型和语法的总结,这一篇是运算相关的操作. 运算符 bash不支持简单的数学计算,需要依赖其他命令实现. expr可以代为实现. # 表达式一般这么写 ` + ...
- shell脚本学习总结02--数组
bash同时支持普通数组个关联数组,普通数组只能使用整数作为数组的索引,关联数组可以使用字符串作为数组的索引. 数组的定义方法: 在单行中使用一列值定义一个数组 [root@new ~]# array ...
- Shell脚本学习指南笔记
Shell脚本学习指南 作者:Danbo 2015-8-3 脚本编程语言与编译型语言的差异 许多中型.大型的程序都是用编译型语言写的,例如:C.C+.Java等.这类程序只要从源代码(Source C ...
- shell脚本学习第一课
shell是一种程序设计语言,是访问操作系统内核的服务. Linux的shell种类常见的有: Bourne Shell(/usr/bin/sh或/bin/sh) Bourne Again Shell ...
- Shell脚本学习 - 基本内容以及数据格式
为了捞取日志,自己用python写了一些东西,大致套路就是读取写入文件的操作,放到linux上跑.实际使用时发现要操作的文件有时比较大,直接打开文件找需要的东西可能会有一些效率问题.所以学习一下she ...
随机推荐
- juqery和dom对象互换
一.jQuery对象与DOM对象相互转换 1.jQuery对象转DOM对象 var $cr = $("#cr"); //jQuery对象 //转换成DOM对象,索引号从0开 ...
- Axure 蚂蚁设计团队组件库 让交互稿美美"搭"
Github资源:https://github.com/ant-design/ant-design-pro English | 简体中文 技术实践篇 https://pro.ant.design/do ...
- 摘: VS2010 C++ 调用 DLL (C++编写)
一.为什么需要dll 代码复用是提高软件开发效率的重要途径.一般而言,只要某部分代码具有通用性,就可将它构造成相对独立的功能模块并在之后的项目中重复使用. 比较常见的例子是各种应用程序框架,如ATL. ...
- Oracle开发者守则
下面为Oracle大师级语录: Oracle Database developers should follow is to do everything they can in SQL. What t ...
- RFID编码
信号编码系统包括信源编码和信道编码两大类,器作用是把要传输的信息尽可能的与传输信道相匹配,并提供对信息的某种保护以防止信息受到干扰.信源编码与信源译码的目的是提高信息传输的有效性以及完成模数转换等:信 ...
- SMBUS讀取數據的方法
第一步 将HST_D0寄存器清零 第二部 确定HST_STS (SMB_BASE 00h)寄存器裡面的所有狀態位是清除的(写清零) 第三步 往XMIT_SLVA(SMB_BAS ...
- 使用digitalocean搭建v·p·s
这几天digitalocean开始猛卡,一顿操作之后连不上了=_=遂复习了一下怎么搭vps 准备工作 事先准备好Putty,直接百度搜索下载即可(也可直接使用digitalocean的access c ...
- 深入理解Spark 2.1 Core (十一):Shuffle Reduce 端的原理与源代码分析
http://blog.csdn.net/u011239443/article/details/56843264 在<深入理解Spark 2.1 Core (九):迭代计算和Shuffle的原理 ...
- android.view.animation(1) - alpha、scale、translate、rotate、set的xml属性和用法(转)
一.ScaleAnimation ScaleAnimation(float fromX, float toX, float fromY, float toY, int pivotXType, floa ...
- CSS3多列布局
通过 CSS3,您能够创建多个列来对文本进行布局 - 就像报纸那样! 在本章中,您将学习如下多列属性: column-count column-gap column-rule 浏览器支持 属性 浏览器 ...