# Filename: vt100_test.sh# Don't forget the command line when you met a permission issue: chmod 777 ./vt100_test.sh# Switch cursor OFFecho -e "\033[?25l" # "\033" equals to "\e", "\e[?25l" works fine toofor i in $(seq 30 37)do# Change text/foreground colorecho -ne "\e[s\e[${i}m hello World 文字颜色测试 [$i] \e[u"# Delay 1 second(s)sleep 1sdoneecho # New blank lineecho -ne "\e[30m"for i in $(seq 40 47)do# Change background colorecho -ne "\e[s\e[${i}m hello World 背景颜色测试 [$i] \e[u"# Delay 1 second(s)sleep 1sdoneecho # New blank line# Change text/foreground color to green and set cursor position to col 40echo -e "\e[32m\e[40C Demo finished."# Switch cursor ON and clear all vt100 commands and settingsecho -e "\e[?25h\e[0m"
将以上代码复制/粘贴入新建的空白文本文件中,文件名保存为 vt100_test.sh,在终端窗口输入命令行 chmod 777 ./vt100_test.sh 设置好文件的访问和执行权限,运行 ./vt100_test.sh 即可浏览VT100终端控制码的应用效果。
