Question: 1e. Write a script which receives a list of parameters. If no parameters are received, output an error message. Otherwise, iterate through the list and,
1e. Write a script which receives a list of parameters. If no parameters are received, output an error message. Otherwise, iterate through the list and, using a case statement, test each item in the list to see if it starts with a capital letter, lower case letter, digit or other. Count each type and output at the end the total for each category (capital, lower case, digit, other).
1f. Write a script to input a list of positive numbers from the user using a while loop (exit the loop upon a negative number), storing each input as an array element. Using a for loop, iterate through the list and compute the sum, average, maximum and minimum elements in the array. Output these results.
1g. Write a script to determine if a parameter supplied to the script is a palindrome or not. A palindrome is a string that reads the same forward and backward. To accomplish this, you will need to loop from 0 to the halfway point in the string and compare the character at location i to the character at location length i 1 where length is the length of the string. If, after passing halfway through, the two compared characters match in each iteration, then output the parameter and that it is a palindrome, else output the parameter and that it is not a palindrome.
1h. Create a script containing a function of the code defined in #17 and code after the function that defines an array of several strings, some of which are palindromes and some of which are not and then code to iterate through the array, calling the palindrome function passing each array element as a parameter.
1i. Examine the file /etc/rc.d/init.d/atd. This is a script that allows the system administrator to control the atd service, starting it, stopping it, etc. This script file consists primarily of a series of functions and a case statement. The idea is that someone calls this program using ./atd command where command is then compared in the case statement which then calls upon one of the functions, or if the command is not legal, it outputs a usage statement. In a similar way, write a script that has a case statement to see if the user has passed the script one of these commands: hello or start, goodbye or stop or quit, help. If hello or start, then call a function which outputs a personalized greeting to the user using the value in the variable $USER and the date. If goodbye/stop/quit, output a goodbye message. If help, output a message that provides a brief explanation on how to use Linux (e.g., Consult man pages, read the textbook, etc). If there is no command or the command is any other word, output a usage statement.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
