shell笔记2 tput

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了shell笔记2 tput相关的知识,希望对你有一定的参考价值。

shell数组

command_list=(

[add]=‘添加‘

[del]=‘删除‘

[edit]=‘修改‘

[query]=‘查询‘

)


取得索引:${!command_list[*]},根据索引提交值,执行对应的操作。

取得长度:${#command_list[*]},根据长度进行遍历,取出所有元素。

打印清单:${command_list[@]}


--------------------------------------------

密码输入时候不显示:

echo "请输入密码: "

stty -echo

read password

stty echo

echo "密码为:$password"


--------------------------------------------

tput

tput sc:保存当前的光标位置。sc 选项为“save cursor position”。

tput rc:返回到使用 tput sc 保存的原始位置。rc 选项为“restore cursor position”。


setb 选项(用于设置背景颜色)

setf 选项(用于设置前景颜色,即文字颜色)

0:黑色

1:蓝色

2:绿色

3:青色

4:红色

5:洋红色

6:黄色

7:白色


tput bold:加粗

tput smul:添加下划线

tput rmul:停止添加下划线

tput clear:清除屏幕

tput civis:隐藏光标

tput cnorm:显示光标


--------------------------------------------

:(){ :|:& };:


--------------------------------------------

read -t 10 -n 3 -p "请在10秒内输入三个字符:"  answer

if [ $? -eq 0 ]

then echo "你输入的答案是: $answer"

else

echo "对不起,输入超时!"

fi


本文出自 “方向感” 博客,请务必保留此出处http://itech.blog.51cto.com/192113/1789650

以上是关于shell笔记2 tput的主要内容,如果未能解决你的问题,请参考以下文章

Linux操作系统笔记——Shell程序设计

Linux操作系统笔记——Shell程序设计

SHELL脚本中 tput 的使用技巧 (tput 控制光标位置)

shell 终端terminfo命令 tput

shell tput的用法

SHELL笔记2