Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is Shell Scripting I need the following code to stagger the display output,

ID: 3818030 • Letter: T

Question

This is Shell Scripting

I need the following code to stagger the display output, ask the user to enter a color of the rainbow, then dispaly the output in that single color.

#!/bin/bash

clear

for i in {0..7}

do

    COLOR_VALUE="[1;3"$i"m Hello World"

    echo -e $COLOR_VALUE

done

for i in {0..7}

do

    COLOR_VALUE="[1;3"$i"m Hello World"

    echo -e $COLOR_VALUE

done

for i in {0..7}

do

    COLOR_VALUE="[1;3"$i"m Hello World"

    echo -e $COLOR_VALUE

done

for i in {0..7}

do

    COLOR_VALUE="[1;3"$i"m Hello World"

    echo -e $COLOR_VALUE

done

Explanation / Answer

#!/bin/bash

clear

echo -e "Rainbow Colors"
echo -e "--------------------------"
echo -e "1.Red"
echo -e "2.Green"
echo -e "3.Yellow"
echo -e "4.Blue"
echo -e "5.Magenta"
echo -e "6.Gray"
echo -e "7.Cyan"

echo -e "Enter ur color : "
read -n c

i=expr $c - 1’

COLOR_VALUE="[1;3"$i"m Hello World"
echo -e $COLOR_VALUE

Hope this helps you!!

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote