Write a bash function called getName that prompts user for a filename, store name in the local variable gotname. Use test to test (test -n ) that gotname is not null. If succesful, display the contents of gotname, Otherwise display nothing and return a code of 1.
Write a bash function called vName that calls the getName function. It should assign the output of getName to a local variable called gotfn. If getName returns success, the use grep to test gotfn for any character other than / (directory separator). Remember to dispose of any output from grep, we only want the success/failure of the string match. If getName failed, return 1. If the grep failed, return 2.
Write a bash function called fileExists that calls vName to get a filename from the user. fileExists will 1st test if vName returned successfully. If not, return the status code of vName, whatever it is. Otherwise test that filename retreived by vName is a regular, readable file in the current directory. If this fails, return a status of 3.
Write a bash script called Restore that uses the select loop to list the contents of $HOME/Backup. Remember to include a quit string in the list. Once the user chooses an option, use trim to trim the extension and store it in another variable. Then copy the selected file to the current directory with the 'trim'med name. Also remember to check choice for the quit and if chosen, quit the program. Assume the trim function is defined and available.
Write a bash case structure that examines the variable ans for the following conditions and takes the specified action. Must be a case structure.
If 00 # 2 zeros exit program. Else if any other 1 or 2 digit number add to sum print sum Else if more than 2 digits (or digits followed by other characters) print "too big" Else if ans has the values up or add increment sum by 1. Else print "not a choice" Endif