Write a bash shell script that will read a list of numbers that are passed as arguments to the script and the output is the numbers passed, their sum and average. If no numbers are passed, the script should output a Usage error.
Added by Manuel B.
Close
Step 1
First, we need to check if any arguments were passed to the script. We can do this by checking the value of the special variable "$#". If it is 0, then no arguments were passed and we should display the usage error message. Show more…
Show all steps
Your feedback will help us improve your experience
Maanya Naveen and 55 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
Q.2 Write a shell script to display sum of digits of given number.
Chandra J.
Write a program that inputs numbers and keeps a running sum. When the sum is greater than 100, output the sum as well as the count of how many numbers were entered. Sample Run Enter a number: 1 Enter a number: 41 Enter a number: 36 Enter a number: 25 Sum: 103 Numbers Entered: 4 Hint: If you get an EOF error while running the code you've written, this error likely means you're asking for too many inputs from the user.
Cora M.
Liam H.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Watch the video solution with this free unlock.
EMAIL
PASSWORD