Question
1)Write a Bash shell script named stars.sh that a. Take 1 number as an argument and prints a triangle of asterisks that is left-aligned. For
1)Write a Bash shell script named stars.sh that
a. Take 1 number as an argument and prints a triangle of asterisks that is left-aligned. For
example, if the argument is 4 prints the following:
*
**
***
****
b. If there is not exactly 1 argument, or the argument is not an integer, or the integer is less
than 1, print an error message and exit
c. Hint: Use for loops
2) Write a Bash shell script named calc.sh that
a. Performs addition (+), subtraction (-), multiplication (x), and integer division (/) math
operations.
b. Takes in 2 operands and 1 operator and prints the result. Example: calc.sh 5 + 3 would
print 8 and calc.sh 9 / 2 would print 4
c. If there are not exactly 3 arguments, or the second argument is not one of the operators in
part (a), or first or third argument is not an integer, print an error message and exit
d. If operator is division (/) and second operand is 0, then print error message error: cannot
divide by 0 and exit
e. Hint: Use case statement
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started