create a shell script that uses if/else and other logical operators to determine
ID: 3690550 • Letter: C
Question
create a shell script that uses if/else and other logical operators to determine the larger of two numbers, and if two strings are equal. For this exercise, the numbers and string values should be hard-wired into the code (e.g. INT1=12, INT2=14, STRING1 = "MOM", STRING2= "DAD") Submit your shell script code, and the results of successfully running your code. Be sure to conduct and describe multiple test cases to ensure your script is working properly for a variety of numbers and string values. You should submit both your code, and your word or PDF document with screen captures showing your results and descriptions and results for your multiple test cases. Your document should be well-organized, well-written with minimal spelling and grammatical errors. The document should include page numbers, figure titles and numbers and section titles as appropriate. Your code should include comments describing the code and header comments with your name, date and purpose of the script.
Explanation / Answer
#!/bin/bash
echo "penetrate first number"
read first
echo "penetrate second number"
read sec
echo "penetrate third number" #Dollar sign used to represent the content
read third
if [ $first -gt $sec ] ; then
if [ $first -gt $third ] ; then
echo -e " $first is greatest number "
else
echo -e " $third is greatest number "
fi #used in scripts
else #Loop
if [ $sec -gt $third ] ; then #Condition
echo -e " $sec is greatest number "
else
echo -e " $third is greatest number "
fi
fi #Ends
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.