Practice Exercise in Bash Basics Series #2: Using Variables in Bash

If you are following the Bash Basics series on It’s FOSS, you can submit and discuss the answers to the exercise at the end of the chapter:

Fellow experienced members are encouraged to provide their feedback to new members.

Do note that there could be more than one answer to a given problem.


Here is my solution:

echo "Today's price is: $price"
echo "Tommorrow's price is: $((2*$price))"

The reason I’ve used double quotes is because of something called “Arithmetic Expansion

PS: Apologies in advance for any confusion caused, I have just started my journey in the world of bash scripting.

The solution is good.

It would have still been fine if you just ‘hardcoded’ the variables :slight_smile: That’s because the arithmetic operations are covered later in the series :slight_smile:

But it’s good that you did your research and learned something in advanced :clap:

1 Like

Thank you for the kind words @abhishek :slightly_smiling_face: