FAQ: Learn Bash Scripting - Aliases


This community-built FAQ covers the “Aliases” 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 Aliases

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!


Hello. I am trying to find out what I did wrong here. This is a copy of my code. The first line starts at number 1.

first_greeting=“Nice to meet you!”
later_greeting=“How are you?”
while [ $greeting_occasion -lt $greeting_limit ]
if [ $greeting_occasion -lt 1 ]
echo $first_greeting
echo later_greeting fi greeting_occasion=((greeting_occasion + 1))

When I try to run my code, I keep getting a unary operator expected error on line 6. Please advise on what I’ve done wrong, because I don’t understand it.


If you write

alias greet3="./script.sh 3"

according to describing (!!on command line) and then write greet3 your script will work.
But I don´t understand why script it can´t be start by normal way???
And why
greeting_limit in the script is written in this way

greeting_limit=$1 ???

I hope I will figure out.


I think the $ sign in greeting_limit=$1 tells it to use the first number that is written by the user in the alias (the first input). So if you try to run it just by typing ./script.sh, you get an error because there is no number for it to use for the greeting_limit.

To complete this exercise, type alias greet3=’./script.sh 3’ in the bash terminal (not in script.sh), then type greet3 to run the script using this alias

You can run the script without the alias by typing ./script.sh and then a single number or a list of numbers, and the script will use the first number that you type. For example, if you type ./script.sh 1 2 3 then the script will run and will show you one greeting.

However - I thought that if you change the script.sh to include greeting_limit=$2 instead of $1 then it would use the second number in a list - but it still appears to use the first number. Any ideas anyone?