Answered step by step
Verified Expert Solution
Question
1 Approved Answer
5. Write a bash script that will accept a parameter, the name of a color, and then output the parameter in a matching font color.
5. Write a bash script that will accept a parameter, the name of a color, and then output the parameter in a matching font color. Requirements for your script: Name your script 25.sh Your script should source a code snippet . Under the Assignment directory, create a directory named snippets In that directory, create a file named Q5 colors Put these commands in Q5 colors RED="\033[31m" GREEN="\033[32m" BROWN="033[33m" BLUE="\033[34" MAGENTA="1033[35m" RESET="\033[Om" Source the Q5 colors file in your script Your script should also use one parameter, $1, which will be the name of a color. You should then set a variable named color to the value of the parameter If the parameter wasn't entered, prompt the user to enter the name of the color and store the value in a variable named color You should then convert the variable color to uppercase. The command to do that is: color=$(echo $color | tr [a-z] [A-Z]) Your script then use a case statement to determine the value of the variable color. You should check for value of the five colors in the Q5colors file, and, if there is a match, output the color with a matching font color The font color should be change back to default after each word is output If there is no match to the five colors, output a message in the default color that states "Some other color" Here's a screenshot of the script in use: whiten1@ubuntuGold :-/Assignments/Assignment7$ ./05.sh Enter a color: red Red whiten1@ubuntuGold :-/Assignments/Assignment7$ ./05.sh red Red whiten1@ubuntuGold:-/Assignments/Assignment7$ ./05.sh Green Green whiten1@ubuntuGold:-/Assignments/Assignment7$ ./05.sh BROWN Brown whiten1@ubuntuGold: Assignments/Assignment7$ ./05.sh blue
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started