Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Could you please provide the code for the shell script. Part 2 - Linux Shell Scr

ID: 3827982 • Letter: C

Question

 Could you please provide the code for the shell script. Part 2 - Linux Shell Scripting - Worth 5 points.     - NOT using editors, create a sh file named: program2.sh     - Set this *.sh file to: chmod 755 *.sh     - NOT using editors, append your name, current date and time to a NEW file called results.txt     - NOT using editors, append to the *.sh file, all the commands needed so that when you execute your sh file,      this file will produce the following:          How:     - Ask the user to enter a number.    - Verify that the number is between 1 and 100.    - If the number is not between 1 and 100, then keep asking the user to enter a number until it is valid.    - Use a for loop from 1 to the value entered by the user     - Sum the results of calculating each number mod 5    - After the for loop ends, display the sum of all previous results and      append it to the results.txt file as follows       Sum of numbers is xxx 

Explanation / Answer

#!/bin/sh

echo "Please enter a list of numbers between 1 and 100. "
read NUMBERS

for NUM in $NUMBERS
do
   if [ "$NUM" -lt 1 ] || [ "$NUM" -gt 100 ]; then
       echo "Invalid Number ($NUM) - Must be between 1 and 100!"
   else
       echo "$NUM is valid."
   fi
done
if (( $num % 5 == 0 ))
then
     echo num
fi
ECHO %num% %results.txt%

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote