shell笔记2 tput
2016-06-15 18:19
357 查看
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
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
相关文章推荐
- android wifi 无线调试
- 运维入门
- 动态清空 nohup 输出文件
- install scrapy with pip and easy_install
- Linux Shell常用技巧
- Shell 脚本编程陷阱
- shell字符串操作详解
- Shell中删除某些文件外所有文件的3个方法
- Ruby中执行Linux shell命令的六种方法详解
- VB使用shell函数打开外部exe程序的实现方法
- Shell编程的一些知识集合
- Shell中的for和while循环详细总结
- 什么是Shell?Shell脚本基础知识详细介绍
- Shell脚本中引用、调用另一个脚本文件的2种方法
- Shell脚本解压rpm软件包
- Linux Shell 数组建立及使用技巧
- Shell脚本实现复制文件到多台服务器的代码分享
- Shell脚本实现批量替换文件内容
- Shell脚本实现的一个简易Web服务器例子分享
- linux Shell学习笔记第五天