Write a Bash alias called Backup that calls the getName alias. If it returns success, then copy the file stored in gotName to $HOME/Backup. When you do this, append the contents of $RANDOM to the filename. Assume filename is a simple filename with no path information.
Write a function, getnum, that prompts the user for a number, reads the number, and uses grep to test for just a number. It may be signed and use a decimal point and following digits. Use redirection to discard any errors. Output the result of grep and set the return code to zero if number found and non-zero if not. This can be done with two lines in the function.
Write a function, chkargs, that takes an argument from the command line and tests that each argument only contains alpha-numeric and underscore. Use grep to test for valid entries, use redirection to discard any errors. Output all correct argument values.
Write a function, Blist, that uses select to list the contents of $HOME/Backup and the additional option quit. The user selects quit, the loop should terminate, otherwise it should do a long listing of selected file in Backup. Note, if you select an invalid choice, select assigns null to the selection variable. Code so that doesn't happen.
Write a while loop that always runs. Follow pseudo code. Useful information, expr can only do integer math, dc can do floats. dc is an rpn calculator.
Two useful commands for the problem. # dc is an interacive RPN calculator that uses a stack to hold values # You can also feed it input from the command line. echo 43 27.2 + p | dc 70.2 # 43 27.2 add print # dc is an interacive algebraic calculator. echo 43 + 27.2 | dc 70.2
In the loop,
Call getnum and assign output to a variable. If getnum returns false, go back to the top of the loop. Else Add number to total # you may use echo the nu Endif If Total > 100 then leave loop. Loop end Display total.
Write a bash case structure that examines the variable ans for the following conditions and takes the specified action. Must be a case structure.
Pseudo code. Assume that the value being tested is the variable ans, which has been assigned a value somewhere else in the script. 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