#!/bin/sh
# Print chessboard --------------->> Method 1
# https://helloacm.com
# Print chessboard --------------->> Method 1
# https://helloacm.com
for i in $(seq 1 8)
do
for j in $(seq 1 8)
do
S=$(((i+j)%2))
if [ $S -eq 0 ]
then
echo -n "\033[47m " # white
else
echo -n "\033[40m " # black
fi
done
echo -n "\033[40m" # black, ensure it exists normally
echo "" # new line
done
Echo "=============================================================="
# Print chessboad --------------->> Method 2
#! bin/bash
for (( i = 1; i <= 9; i++ )) ### Outer for loop ###
do
for (( j = 1 ; j <= 9; j++ )) ### Inner for loop ###
do
tot=`expr $i + $j`
tmp=`expr $tot % 2`
if [ $tmp -eq 0 ]; then
echo -e -n "\033[47m "
else
echo -e -n "\033[40m "
fi
done
echo -e -n "\033[40m" #### set back background colour to black
echo "" #### print the new line ###
done