Bash Shell Scripting

Table of Contents

Shell Scripting lets you to automate command line tasks. Learn how to automate tasks with our beginner's tutorial guide.

  1. Setup
  2. Get started on the fundamentals of writing a shell script. Learn about how to write and execute your first shell script.

    1. Setup
    2. Learn how to write and execute your very first shell script.

    3. Important Symbols and Characters
    4. Learn about the important symbols in shell-scripting and how to use them in commenting, declaring she-bangs, and signifying the end of a command.

    5. Execution
    6. Learn how to execute a shell script like any other command.

  3. Variables
  4. Learn how to declare variables, manipulate variables, and call special variables.

    1. Variables
    2. Learn about the naming conventions used in variables, how to assign values and unset them.

    3. Manipulating Variables
    4. Learn how to find the length of a variable, make variables read-only, make variables persist to subshells, and unset variables from their values.

    5. Substitution Operators
    6. Learn how to handle cases when your variables aren't set with expansion operators.

    7. Positional Parameters and Special Characters
    8. Learn about the positional parameters used in the shell that denote arguments, number of arguments and script name. Also learn about special characters.

  5. Input and Output
  6. Learn how to print to standard out, read from standard in and redirect standard in, out and error.

    1. Standard out with echo and prinf
    2. Learn how to use the echo and printf commands to output variables, and see the difference between single and double quotes.

    3. Quotes review
    4. Let's do a quick review on the different types of quotes - double, single, and ticks.

    5. I/O Redirection
    6. Learn how to use redirection to change manipulate standard input, output and error. Also find out how to append to a file and create pipelines.

    7. Reading user input
    8. Learn how to read user input with the read command and try writing a sample script that gets a user's name and outputs it back out.

  7. Control Flow Statements
  8. Learn all about control flow statements, including exit statuses, logical expressions, file, string, arithmetic tests, if-else and case statements.

    1. Exit Codes / Statuses
    2. Learn about exit statuses, how to retrieve the last exit status, POSIX exit statuses.

    3. Evaluating Logical Expressions with test
    4. Learn how to use the test command, or the [ symbol to evaluate logical expressions.

    5. File Tests
    6. Perform tests on a file to see if it exists, what type it is, and its permissions settings. Furthermore, compare it to another file with the comparison operator.

    7. String Tests
    8. Learn how you can use string tests to check two strings for equality and null values.

    9. Arithmetic expansions and tests
    10. Learn how to get the shell to evaluate arithmetic equations, and how to test with numbers.

    11. If-else statements
    12. Learn how to write an if-else statement in shell scripting and make your own coin-tossing game!

    13. Case statements
    14. Learn how to simplify if-else statements with the case construct. Also learn how to build a rock-paper-scissors game through shell scripting!

  9. Looping
  10. Learn how to write for, while, until loops on shell scripting for the Linux (bash). Also learn control flow techniques such as continue and break to direct your looping control flow.

    1. For loops
    2. Learn how to use for loops in the unix / linux bash shell scripting language.

    3. While loops, shift and getopts
    4. Learn how to write Linux shell scripting (bash) while and until loops, with examples. Also learn about the shift and getopts commands.

    5. Until loops
    6. Learn how to write until loops in bash shell scripting.

    7. Looping control flow
    8. Learn how to direct control flow in loops with the continue and break keywords.

  11. Sed
  12. Learn how to use sed to filter and transform text.

    1. Introduction
    2. Introduction to using sed on the command line with regular expressions. Learn how to perform search and replace (substitution), printing, writing, reversing, and more!

    3. Line addresses and Printing
    4. Learn how to specify a line address to apply your sed command, and print out text.

    5. Deleting Lines and Saving Processed Files
    6. Learn how to use sed to delete lines in-place from files and standard in, and save edited files.

    7. Substituting (Search and Replace)
    8. Learn how to use substitution (search and replace) with the sed command.

    9. Backreferences and Ampersands
    10. Learn how to reference an earlier regular expression with backreferences or the entire matched phrase with ampersands.

    11. Applying multiple sed commands with sed scripts
    12. Learn how to apply multiple sed commands with the -e option, the semicolon (;) or with sed scripts

    13. Writing to a file
    14. Learn how you can write up to ten files in sed per instance.

    15. The Hold Buffer
    16. Learn about the hold buffer, which is like the pattern buffer but for storing and retrieving lines for later use.

  13. Awk
  14. Learn GNU awk programming for bash through our tutorial series for beginners.

    1. Introduction to AWK
    2. Learn what awk is, the origins of the name, its features and some of awk's variations.

    3. Workflow: BEGIN, BODY, and END blocks
    4. Learn about awk's workflow with the BEGIN, BODY and END blocks.

    5. Records and Fields
    6. Learn how awk operates through records and fields, its separators and field accession variables.

    7. Patterns and Actions
    8. Learn about how awk uses patterns and actions to specify which records and fields to manipulate.