FAQ: Learn Bash Scripting - Review


This community-built FAQ covers the “Review” exercise from the lesson “Learn Bash Scripting”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Web Development

Learn the Command Line

FAQs on the exercise Review

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!


The BASH CLI course is far too narrow and, AFAIC, incomplete.


It really seems like this Bash Scripting course stops short. Can somebody tell me about, for example, functions?

I’ve done some research, but I can’t get my function to return anything. When I call the function, instead of returning a number, it apparently returns the name of the function.

Here’s my code:


get_number() {
	return 6

echo $boolean_number

Out of the code above, all I get in the terminal window is get_number

Can someone help me, please?


That’s not the name of the function, that’s just text which happens to be the same characters as the name of the function. You’d need to evaluate that expression to obtain its result.

You might also want to write the result of your function to stdout rather than setting an exit value.


Well, how do I properly call the boolean_number function and assign it’s return value to the boolean_number variable?

Also, can you confirm that I don’t have any syntax errors in my function?


You…don’t. They’re not conventional functions. They’re more like programs.
If you wanted such behaviour you should likely be looking for something like perl/python/ruby/whatever.

bash isn’t a programming language as much as it is just glue between other programs
You can certainly encode logic with it but err. Yeah. That’s not quite what it is.


So, the first thing to note is that your expectations don’t apply.

But you can get similar behaviour. Like mentioned, you’d probably print the result instead. You can also set a variable which the caller can look at afterwards.

add() {
    echo "$1 + $2" | bc

echo $(add 1 2)

add() {
    returnvalue=$(echo "$1 + $2" | bc)

add 1 2
echo $returnvalue
unset returnvalue

Oh and getting quoting right is a bit of a nightmare so, again, you might want to prefer to just not, and instead use some… uh. you know. programming language.


Oh. Okay. That’s too bad