Write a script named lastname_firstname_checking.sh that does the following:
who
command and pipe it to grep).username is not logged on.
ps -aux and pipe it to grep.)
Write a “calculator” program in a script
named lastname_firstname_calculator.sh. This
script will ask users
to enter a simple expression of the form
number operator number, where the numbers
are integers and the operator is either
+, -, *, or /. If
the operator is not one of those four, you should produce an error message.
Your script must use the case construction.
In order to assign an asterisk * to a
variable without having
bash expand it as a pathname, you must put the following
line in your script before you start processing user input:
GLOBIGNORE='*'
awk to get the numbers.
Set the delimiter string to '[+*/-]'. Note that the dash
must come either first or last in the square brackets to avoid being
interpreted as a character range.awk.
--only-matching option to grep
to extract the operator. Normally, grep echoes the entire line
when it finds a pattern; this option shows only the part of the line that
matched. Example:
echo "concatenate" | grep 'c[aeiou]t' concatenate echo "concatenate" | grep --only-matching 'c[aeiou]t' cat
echo -n to keep the cursor on the same line as
your prompt.Here is sample output from several runs of the program. Your program does not have to give exactly these prompts and error messages, but it must exhibit similar behavior.
Enter expression: 3 + 5 8 Enter expression: 15 - 2 13 Enter expression: 12*144 1728 Enter expression: 1892/4 473 Enter expression: 3^2 Unknown or missing operator in 3^2
Make sure the script files are named in the form lastname_firstname_checking.sh and lastname_firstname_calculator.sh, and email them to the instructor. Put the word CIT052 in the subject line of your email, please.