#!/bin/bash
PS3="please choice the first color :"
select color1 in hong lv huang lan zi qianlan bai hei ;do
[[ $REPLY =~ ^[1-8]$ ]] || { echo must 1-8;continue; }
case $color1 in
hong)
echo -e the first color is "\033[1;41m \033[0m"
break
;;
lv)
echo -e the first color is "\033[1;42m \033[0m"
break
;;
huang)
echo -e the first color is "\033[1;43m \033[0m"
break
;;
lan)
echo -e the first color is "\033[1;44m \033[0m"
break
;;
zi)
echo -e the first color is "\033[1;45m \033[0m"
break
;;
qianlan)
echo -e the first color is "\033[1;46m \033[0m"
break
;;
bai)
echo -e the first color is "\033[1;47m \033[0m"
break
;;
hei)
echo -e the first color is "\033[1;48m \033[0m"
break
;;
esac
done
PS3="please choice the second color :"
select color2 in hong lv huang lan zi qianlan bai hei ;do
[[ $REPLY =~ ^[1-8]$ ]] || { echo must 1-8;continue; }
case $color2 in
hong)
echo -e the first color is "\033[1;41m \033[0m"
break
;;
lv)
echo -e the first color is "\033[1;42m \033[0m"
break
;;
huang)
echo -e the first color is "\033[1;43m \033[0m"
break
;;
lan)
echo -e the first color is "\033[1;44m \033[0m"
break
;;
zi)
echo -e the first color is "\033[1;45m \033[0m"
break
;;
qianlan)
echo -e the first color is "\033[1;46m \033[0m"
break
;;
bai)
echo -e the first color is "\033[1;47m \033[0m"
break
;;
hei)
echo -e the first color is "\033[1;48m \033[0m"
break
;;
esac
done
read -p "please input the number of space: " n
until [[ $n =~ ^[[:digit:]]+$ ]];do
echo "must be a number"
unset n
read -p "please input the number of space: " n
done
hong () {
for a in `seq $n`;do
echo -e "\033[1;41m \033[0m\c"
done
}
lv () {
for b in `seq $n`;do
echo -e "\033[1;42m \033[0m\c"
done
}
huang () {
for c in `seq $n`;do
echo -e "\033[1;43m \033[0m\c"
done
}
lan () {
for d in `seq $n`;do
echo -e "\033[1;44m \033[0m\c"
done
}
zi () {
for e in `seq $n`;do
echo -e "\033[1;45m \033[0m\c"
done
}
qianlan () {
for f in `seq $n`;do
echo -e "\033[1;46m \033[0m\c"
done
}
bai () {
for g in `seq $n`;do
echo -e "\033[1;47m \033[0m\c"
done
}
hei () {
for h in `seq $n`;do
echo -e "\033[1;48m \033[0m\c"
done
}
declare -i i=1
while [ $i -le 8 ];do
if [ $[i%2] -eq 0 ];then
declare -i j=1
while [ $j -le 8 ];do
if [ $j -eq 4 ];then
`echo $color1`;`echo $color2`
echo
let ++j
continue
fi
`echo $color1`;`echo $color2`
let ++j
done
echo
else
declare -i k=1
while [ $k -le 8 ];do
if [ $k -eq 4 ];then
`echo $color2`;`echo $color1`
echo
let ++k
continue
fi
`echo $color2`;`echo $color1`
let ++k
done
echo
fi
let ++i
done
shell脚本:自定义大小颜色的国际象棋棋盘
最新推荐文章于 2023-04-09 23:34:52 发布