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!!
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.