Learn Bash Scripting by Building Five Programs - Build Five Programs

Tell us what’s happening:
I am doing learn Learn Bash Scripting by Building Five Programs until exercise:

You used the double square brackets with your if statement in the last program, but you can use the double parenthesis with these operators as well. In your script, create an if statement that uses double parenthesis for the condition. Check if the number variable is less than or equal to 15. If it is, use your two variables to print The next number is, B:<number> .

I try add to if statements below does not complete. It was error: Your script should have the suggested “if” statement added correctly

My source code:

#!/bin/bash

# Bingo Number Generator
echo -e "\n~~ Bingo Number Generator ~~\n"
NUMBER=$(( RANDOM % 75 + 1 ))
echo $NUMBER
TEXT="The next number is, B:<number>"

if (( NUMBER <= 15 ))
then
  echo $TEXT B:$NUMBER
fi

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36

Challenge: Learn Bash Scripting by Building Five Programs - Build Five Programs

Link to the challenge:

Please help me to solve this error. Thank you so much.

should NUMBER be $NUMBER?

1 Like

I fixed. Thank you so much!

1 Like

Not works in my case. Both variants (with $NUMBER and NUMBER) works fine in console but same error in CodeRoad: “Your script should have the suggested “if” statement added correctly”

solved: run same code from my Mac and all works fine. In Сhrome on Windows - not works!!!

#!/bin/bash

Bingo Number Generator

echo -e “\n~~ Bingo Number Generator ~~\n”

NUMBER=$(( RANDOM % 75 + 1 ))

TEXT=“The next number is, B:”

if (( $NUMBER <= 15 ))

then

echo $TEXT B:$NUMBER

fi

#!/bin/bash

---- SOLUTION REMOVED —

#This the full code it accepted

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.