Skip to content

Instantly share code, notes, and snippets.

@asachs01
Last active November 16, 2016 02:25
Show Gist options
  • Save asachs01/5b745f804af70e76b44b12709c3c4fa5 to your computer and use it in GitHub Desktop.
Save asachs01/5b745f804af70e76b44b12709c3c4fa5 to your computer and use it in GitHub Desktop.

Learning Bash Scripting Basics

This is a short gist to teach basic scripting. It's meant for beginners. For each and every exercise, you should comment exactly what each line does.

Concepts

Below is a list of concepts you should be familiar with, and should be able to answer.

  • The Shebang: What is a shebang? Why should you use it in a script? What does it do?
  • Variables: What are variables? How are they used?
  • Built-In Variables: What are built-in(internal) variables?

Basic Exercises

  1. Start off by writing a simple 'Hello World' script called helloworld.sh. It should be able to be run by typing ./helloworld.sh in your terminal
  2. Iterate on the script above so that it does the following: Prompt for your name, and greet you with 'Hello, <YOURNAME>!'
  3. Iterate on the script you just wrote so that it does the following: Takes input for 2 names, and then introduces those two names to each other. Example: Hi Bob, this is Tom. Tom, this is Bob.

Resources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment