1. # Filename: vt100_test.sh
    2. # Don't forget the command line when you met a permission issue: chmod 777 ./vt100_test.sh
    3. # Switch cursor OFF
    4. echo -e "\033[?25l" # "\033" equals to "\e", "\e[?25l" works fine too
    5. for i in $(seq 30 37)
    6. do
    7. # Change text/foreground color
    8. echo -ne "\e[s\e[${i}m hello World 文字颜色测试 [$i] \e[u"
    9. # Delay 1 second(s)
    10. sleep 1s
    11. done
    12. echo # New blank line
    13. echo -ne "\e[30m"
    14. for i in $(seq 40 47)
    15. do
    16. # Change background color
    17. echo -ne "\e[s\e[${i}m hello World 背景颜色测试 [$i] \e[u"
    18. # Delay 1 second(s)
    19. sleep 1s
    20. done
    21. echo # New blank line
    22. # Change text/foreground color to green and set cursor position to col 40
    23. echo -e "\e[32m\e[40C Demo finished."
    24. # Switch cursor ON and clear all vt100 commands and settings
    25. echo -e "\e[?25h\e[0m"

    将以上代码复制/粘贴入新建的空白文本文件中,文件名保存为 vt100_test.sh,在终端窗口输入命令行 chmod 777 ./vt100_test.sh 设置好文件的访问和执行权限,运行 ./vt100_test.sh 即可浏览VT100终端控制码的应用效果。