Need help thank you The following shell script is used to ch

Need help thank you.
The following shell script is used to check if the numbers from command line are even or odd. 1/bin/bash 2 3 count = 0 4 for $num in {$@} 5 do 6 if i expr $num % 2 == 0] 7 then 8 echo $num is an even number 9 count= \'expr $count+1\' 10 else 11 echo $num is an odd number 12 fi 13 14 15 echo There are $count even numbers in total. Which line(s) is(arc) incorrect? And how to correct it(them)? Please write down your solution for that line (those lines).

Solution

#!/bin/bash

count = 0
for $num in {$@}
do
if[ expr $num % 2 == 0]
then
echo \"$num is an even number\"
count = expr $count+1
else
echo \"$num is an odd number\"
fi
done

echo \"There are $count even numbers in total\"

Need help thank you. The following shell script is used to check if the numbers from command line are even or odd. 1/bin/bash 2 3 count = 0 4 for $num in {$@} 5

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site