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.

1 Like

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?

1 Like

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.

1 Like

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.

1 Like

Oh. Okay. That’s too bad

1 Like

Hello to everyone!

Could someone please be so kind as to explain some things to me?

So far I had no trouble understanding other lessons but this one in particular I cant understand. For example I don’t understand the meaning behind this part of code “index=$((index + 1))”…why do we write that, what is its purpose, why “+1”…Other lessons breakdown each command word by word and explain what each word does basically, what is the logic behind it. Here I have no clue what this means and what is its purpose. As a result, I do not understand the result that is produced from the code we build in this chapter.

while [ $greeting_occasion -lt 3 ]
if [ $greeting_occasion -lt 1 ]
echo $first_greeting
echo later_greeting fi greeting_occasion=((greeting_occasion + 1))

Why does it produce just 2 “How are you?” statements if this is a loop? the variable does not change (remains equal to 1). If I am not mistaken the while loop basically loops the same output over and over again as long as the variable meets a certain condition.

Then we go to Inputs…here I cant even begin to understand what I want to ask…The exercise tells us to get user input and assign it to the variable greeting_limit…and replace the number 3 with that variable(prepended $)…is ‘read’ adopting whatever ‘echo’ follows? I am lost…

Please if someone could shed some light for this particular last chapter(5) of Learn command Line… I wish I could ask better questions but I am too confused. And again this is the first time I felt this way into a lesson.

Thank you in advance!

1 Like

I agree. The course was great, and provided explanations for each command as well as how it might be useful when coding IRL. But this Bash section just confused me, and I can honestly say that I have no idea why I did what I did, what the purpose of the commands is exactly IRL, and how input arguments, aliases, conditionals, loops, or anything else in this section, fits together. This was horrible. And it began at the beginning with the first command: #!/bin/bash (pray tell what does the “#” do, or even the “!”). This was frustrating, and not at all worthy of being approved for beginners.

1 Like

Glad to see I am not the only one who struggled with this…I was so frustrated and was starting to believe I am a dummy hahaha