Decisions

Assignment 7

  1. Write a program called valid that prints "yes" if its argument is a valid shell variable name and "no" otherwise. (Hint: Define a regular expression for a valid variable name and then enlist the aid of grep or sed.) (Exercise question 1)
  2. Write a program called t that displays the time of day in a.m. or p.m. notation rather than in 24-hour clock time. Use the shell's built-in integer arithmetic to convert from 24-hour clock time. (Exercise question 2)
  3. Repeat question 2 using a case statement.
  4. Write a program called isyes that returns an exit status of 0 if its argument is "yes," and 1 otherwise. For purposes of this exercise, consider y, yes, Yes, YES, and Y all to be valid "yes" arguments. Write the program using case command. (Exercise question 4)