shell脚本打印国际象棋棋盘
2019-05-22 18:03
1926 查看
本文实例为大家分享了shell打印国际象棋棋盘的具体代码,供大家参考,具体内容如下
代码如下:
#!/bin/bash #set chess cell's width read -p "Please set the chess cell's width( two space width as unit ):" width if [[ $width =~ "^[0-9]+$" ]];then echo "wrong width setting, check your input and try again." exit fi let width=$width*2 #choose player's board cell color player="player1" PS3="Which color do you want to set for $player :" select choice in red green yellow blue purple cyan white;do case $REPLY in [1-7]) if [[ $player == player2 ]];then declare -i color2=$REPLY break else declare -i color1=$REPLY fi player="player2" PS3="Which color do you want to set for $player :" ;; *) ;; esac done if (( color1==color2 ));then echo "two player must choose different color, check your choice and try again." exit fi #print the chess board for (( i=0; i<4; i++ )); do for (( j=0; j<$width/2; j++ ));do for (( k=0; k<4; k++ ));do echo -e "\e[4${color1}m$(printf %${width}s)\e[0m\c" echo -e "\e[4${color2}m$(printf %${width}s)\e[0m\c" done echo done for (( j=0; j<$width/2; j++ ));do for (( k=0; k<4; k++ ));do echo -e "\e[4${color2}m$(printf %${width}s)\e[0m\c" echo -e "\e[4${color1}m$(printf %${width}s)\e[0m\c" done echo done done
参考文章:
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。
您可能感兴趣的文章:
相关文章推荐
- docker安装 搭建私库 删除私库镜像 打印私库镜像 的shell脚本
- linux bash shell 在控制台打印 8格棋盘的方法
- shell脚本练习二(打印乘法表、等边三角形、菱形)
- 查看: 35330 | 回复: 9 打印 上一主题 下一主题 [学习共享] 转:Shell 编程--本文结合大量实例阐述如何编写一个shell脚本
- shell脚本打印日志方法
- Shell脚本攻略01-简介/终端打印
- java打印出国际象棋棋盘
- 打印出国际象棋棋盘.
- shell脚本打印多行文本到文件
- 打印国际象棋棋盘
- Shell脚本:打印九九乘法表
- shell脚本调试打印日志问题
- Linux的shell脚本打印图形和主机监控脚本练习
- shell之打印数组的键与值及常用查询脚本
- shell脚本颜色打印输出
- 在Setting中增加一项用来执行shell脚本,将脚本打印信息显示在Alertdialog中。
- shell下打印菱形(一起熟悉shell脚本编程)
- [转]shell脚本打印日志方法
- shell脚本将服务器信息打印出来
- shell脚本--echo和printf打印输出