Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Terminal assignment. Need explanation of each step. It it sometimes useful to be able to quickly count columns in a terminal window. For this assignment,
Terminal assignment. Need explanation of each step.
It it sometimes useful to be able to quickly count columns in a terminal window. For this assignment, you will write a bash script called ruler which will display a ruler Arguments ruler ill take one optional command-line argument ruler ruler half rulern If no arguments are given, use the environment variable COLUMNS to determine the length of the ruler. If COLUMNS is not set, assume eighty columns. If the word "half" is given, display a ruler half as wide (round down) as would be otherwise displayed, if no arguments were given. If a single numeric argument is given, display a ruler that wide Examples Here are some examples, where % is my prompt: echo $COLUMNS 80 %./ruler 12345678901234567890123456789012345678901234567890123456789012345678961234567890 /ruler half 1234567890123456789012345678901234567890 % . / ruler 27 123456789012345678901234567 Requirements You may not change, add, or remove from the required output. This implies that extra messages are forbidden. Your program should emit a helpful error message if too many arguments are given . an argument 1 is given . a bad argument is given If your program emits an error message, it should not emit anything else. For example, given the argument "bonehead', it would be wrong for the program to complain about that argument, and then go on to display a ruler In cases where multiple requirements are violated, it doesn't matter which requirement you complain about. Pick one, complain, and that should be all. This must be a pure bash script, and not use any other languages such as perl or awk. You may use programs such as sed or grep. Don't be concerned about leading zeroes in numbers. They are used by bash to indicate octal (base 8). We will not test your program with leading zeroes. If the requested length is wider than the terminal, it will look bad. Thats ok. Ruler lengths 2 100 will not be tested. The first line of your script must be: #1 /bin/bash Your script must include a comment block after the first line that contains: your name, course, assignment, and dateStep 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