You can set up aliases for your bash scripts within your .bashrc or .bash_profile file to allow calling your scripts without the full filename. For example, if we have our saycolors.sh script, we can alias it to the word saycolors using the following syntax:

alias saycolors='./saycolors.sh'

You can even add standard input arguments to your alias. For example, if we always want “green” to be included as the first input to saycolors, we could modify our alias to:

alias saycolors='./saycolors.sh "green"'



Our script is updated to take an argument for the number of times the user wants to be greeted:

./script.sh 5 #greets 5 times

Let’s create an alias so that when you type greet3 in the terminal, our script greets you three times.

In your own environment, you could add this alias to your ~/.bashrc to make the alias active every time the terminal is started.

Here, just make the alias in the command line.


Test out your new alias!

Sign up to start coding

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?