Log in from a computer to take this course

You'll need to log in from a computer to start Introduction to Linux. But you can practice or keep up your coding streak with the Codecademy Go app. Download the app to get started.

apple storegoogle store
Learn

Take a minute to review what you’ve learned about bash scripting.

  • Any command that can be run in the terminal can be run in a bash script.
  • Variables are assigned using an equals sign with no space (greeting="hello").
  • Variables are accessed using a dollar sign (echo $greeting).
  • Conditionals use if, then, else, fi syntax.
  • Three types of loops can be used: for, while, and until.
  • Bash scripts use a unique set of comparison operators:
    • Equal: -eq
    • Not equal: -ne
    • Less than or equal: -le
    • Less than: -lt
    • Greater than or equal: -ge
    • Greater than: -gt
    • Is null: -z
  • Input arguments can be passed to a bash script after the script name, separated by spaces (myScript.sh “hello” “how are you”).
  • Input can be requested from the script user with the read keyword.
  • Aliases can be created in the .bashrc or .bash_profile using the alias keyword.

Instructions

Our completed script is in the code editor. Feel free to edit it to make it your own.

Some ideas:

  • ask the user for different greetings
  • add more than two greetings
  • add more conditions to adjust the greetings over time

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?