Bash

echo "Hello, BASH!"

Table of Contents

  1. Why write Shell Scripts?
  2. What is Bash Shell Scripting?
  3. Shell Scripting Fundamentals
    1. Standard Output and Comments

Why write Shell Scripts?

‘Cause having your computer do something you do daily on your behalf is fantastic.

What is Bash Shell Scripting?

Bash is a Unix Shell, allowing a user to interact with an operating system by entering commands.

Shell Scripting is to write Bash Scripts to run in the Bash Shell. Unfortunately, I need to look up the syntax every time I write it, so included here are primarily the fundamentals from miscallaneous sources.

Shell Scripting Fundamentals

A Shell Script is essentially a set of unix programs running sequentially, with control flow. It can be saved to any filename (though preferably one with a .sh extension,) and made executable with chmod +x <filename>. The first line in any shell script should be #!/bin/sh. (Do note that you can also specify zsh, bash, csh, etc.)

Standard Output and Comments

Single line comments, the only comments, begin with an octothorpe #. The echo program is called to send standard output.

# Here, I'll print a simple string:
echo "a simple string. No semicolon needed."

…Aaaand, I’ll get to the rest of this page eventually. I’ll just leave one of my favourite quotes here:

…and my Dad always used to say, if you think the World should be a certain way, you have to be a part of the change you want to see in the World, or you should shut the fuck up and stop bitching about it.

- Louis Rossman


CC BY-SA 4.0 - This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. You are free to share, redistribute and adapt the material as long as appropriate credit is given, and your contributions are distributed under the same license.