Task

Display a series of vertical color bars across the width of the display.

The color bars should either use:

   the system palette,   or 
   the sequence of colors: 
   black
   red
   green
   blue
   magenta
   cyan
   yellow
   white


#!/bin/sh
clear
WIDTH=`tput cols`
HEIGHT=`tput lines`
NUMBARS=8
BARWIDTH=`expr $WIDTH / $NUMBARS`
 
l="1"    # Set the line counter to 1
while [ "$l" -lt $HEIGHT ]; do
  b="0"    # Bar counter
  while [ "$b" -lt $NUMBARS ]; do
    tput setab $b
    s="0"
    while [ "$s" -lt $BARWIDTH ]; do
      echo -n " "
      s=`expr $s + 1`
    done
    b=`expr $b + 1`
  done
  echo    # newline
  l=`expr $l + 1`
done
 
tput sgr0    # reset