How to resolve the algorithm Colour bars/Display step by step in the UNIX Shell programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Colour bars/Display step by step in the UNIX Shell programming language
Table of Contents
Problem Statement
Display a series of vertical color bars across the width of the display. The color bars should either use:
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Colour bars/Display step by step in the UNIX Shell programming language
Source code in the unix programming language
#!/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
You may also check:How to resolve the algorithm Polymorphic copy step by step in the Ruby programming language
You may also check:How to resolve the algorithm Equal prime and composite sums step by step in the Raku programming language
You may also check:How to resolve the algorithm Generate lower case ASCII alphabet step by step in the WebAssembly programming language
You may also check:How to resolve the algorithm String interpolation (included) step by step in the PureBasic programming language
You may also check:How to resolve the algorithm Ordered words step by step in the FutureBasic programming language