Shell Script Programming is of lots of fun. The following script prints a chess board with 8×8 squares interleaving black and white. Using simple loops
and some simple math yields the chess board printing.
#!/bin/sh
# 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
This will print the following roughly. Please note that printing the black and white squares using echo command should take the special characters. The looping in BASH Shell can be reviewed at [here].

In [here], the script has been converted to Windows Batch.
BASH Programming/Shell
- Alarming on High Disk Usage using BASH, AWK, Crontab Job
- Compute GCD in Bash with Input Validation
- Why a Leading Space in Linux Shell Commands Can Matter?
- How to Get HTTP Response Code using cURL Command?
- Three Interesting/Fun BASH Commands
- One Interesting Linux Command (Steam Locomotive in BASH)
- Simple Bash Function to Repeat a Command N times with Retries
- How to Extract a Domain Name from a Full URL in BASH?
- BASH Function to Compute the Greatest Common Divisor and Least Common Multiples
- BASH Function to Get Memory Information via AWK
- BASH Function to Escape Parameters Argument
- BASH Function to Check if sudo Available
- Full Permutation Algorithm Implementation in BASH
- BASH Function to Install Docker
- A Simple BASH Function/Script to Run a Command in Background
- BASH Script to Compute the Average Ping to a Domain
- A Bash Process Controller to Start, Stop and Restart an Daemon Program
- Linux BASH shell - Echo This if you get angry
- Bash SHELL, Chess Board Printing
–EOF (The Ultimate Computing & Technology Blog) —
240 wordsLast Post: 301 and 302 Redirects
Next Post: Large Address Aware