
Attached to this lecture is the Power Point Slides for the Learn Bash Quickly Course.
Ensure you master the Linux command line and basic commands before bash scripting, building comfort with loops and if conditions; a free pdf version of Learn Linux Quickly supports learning.
We cover ten modules, starting with hello world bash script, then variables, arguments, arrays, arithmetic, and string operations, followed by if conditions, switch cases, and loops, ending with batch automation.
Explore how to create a Linux virtual machine using VirtualBox, VMware Fusion, and VMware Workstation Player, plus cloud options like Azure and AWS, with Raspberry Pi as a practical alternative.
Learn to create an Ubuntu Linux virtual machine on Azure, including joining a free account, selecting region and image, configuring CPU and memory, and connecting via SSH with multiple clients.
Learn to create an Ubuntu virtual machine on VMware Workstation Player by downloading the software and Ubuntu ISO, then setting up a 64-bit Ubuntu 20.04 VM with easy install.
Create and run your first shell script in a scripts directory, writing Hello.sh and echoing 'Hello, friend.', then convert it to a bash script, edit path, and add comments.
Add the shebang line #!/bin/bash to designate a bash script, then make it executable and run it with ./hello.sh. Learn how the current directory and path variable affect script execution.
edit the path variable by appending your scripts directory and export PATH, so the shell searches the searchable paths and runs scripts by name without full paths.
Add comments to bash scripts to improve readability and documentation by prefixing lines with a hash, explaining what commands or functions do, while the shebang line remains non-comment.
Explore using bash variables to make scripts dynamic, learn to read user input with read, reference variables with $name, and the importance of double quotes for variable expansion.
Explore how bash treats variables as untyped, letting numbers, strings, or characters share a single variable. The lecture demonstrates this with age, color, year, distro, and pi.
Declare and use constant variables in bash by prefixing with read only, preventing reassignment; illustrate with pi (3.14159) and its role in calculations.
Master command substitutions in bash by capturing command output into variables with the modern $(...) syntax. Compare it to backticks, noting nesting and space sensitivity.
Transform a static hello script into a smart bash greeting by using command substitution with who am I to greet the current user, even when running with sudo.
Learn to pass a single argument to a bash script using $1, replacing prompts with arguments, and count file lines with wc -l using examples like /etc/passwd.
pass multiple arguments to a bash script, count lines in several files with wc, and handle missing arguments in a simple linux automation workflow.
Explore special bash variables like $0, $#, $@, $?, $$, and $!, and learn to display a script name, argument count, all arguments, and last command exit status.
Learn how to create and use arrays in Bash scripts, including accessing, adding, and deleting elements, and creating arrays of different data types to organize multiple items efficiently.
Learn to access bash array elements with zero-based indices, print in reverse order, and display all elements or count them using array syntax like ${array[@]} and ${#array[@]}.
Append an element to a Bash array using plus equals, display the array before and after, and verify the new element is added to the end.
Learn how to delete bash array elements by index using unset, remove entire arrays or variables, and follow practical examples showing before and after results.
Create a hybrid array in bash that holds username, user id, groups, and default shell, then echo each element; bash is untyped and allows mixed data in an array.
Master bash basics by performing addition and subtraction, then multiplication and division, and powers and remainders, culminating in a calculator that converts Celsius to Fahrenheit.
master multiplication and division in bash with a script that converts gigabytes to megabytes (x1024) and prints results, using bc -l for decimals.
Learn Bash power and remainder operations by passing two arguments to a script, using a and b, with double star for exponentiation, percent for remainder, and display results.
Learn how to work with strings in bash, including getting string length, concatenation, substring search and extraction, substring replacement and deletion, and case conversion.
Discover how to concatenate strings in Bash by combining string one and string two to form string three, where order matters, and echo the result.
Learn to extract substrings in bash using a starting index and optional length with zero-based indexing, demonstrated by obtaining fedora and operating from a string.
Replace substrings in bash by updating a string variable, swapping fedora with ubuntu and free with popular. Commit changes by assignment, not just echoing.
Learn to delete substrings in bash by removing single or all occurrences using single and double forward slashes, and update variables with assignment.
Learn how to convert between uppercase and lowercase letters in bash strings using techniques like double carrot sign, double comma sign, and character class, with practical examples.
Master bash decision making with if statements, elif, else, nested ifs, and case statements to drive scripts with test conditions.
Learn bash quickly demonstrates using an if-else statement in bash, with true and false branches, an else clause, and fi. It shows root versus regular user outputs and sudo-driven behavior.
Learn to write bash conditional logic using the elif statement, teaching if, elif, else, and fi with an age-based example.
Master nested if statements in bash with a weather script, using an outer condition of temperature greater than five and inner checks for cold, nice, or hot.
Discover how to use bash case statements as a readable alternative to nested ifs, testing a variable against patterns like a-z, A-Z, and 0-9, and closing with esac.
Discover how bash test conditions compare numbers, files, and strings using operators like -eq and -ne, and file predicates -e, -d, -f, -L.
Explore how to use and create loops in Bash, including C-style and Python-style for loops, while and until loops, array traversal, break and continue, and strategies to avoid infinite loops.
Learn Bash list and range style for loops, modeled after Python, iterating over numbers, strings, or files such as /var/*, with for, do, and done syntax.
Learn to implement a Bash while loop by initializing a counter, testing the condition, and printing the first ten multiples of three, as an alternative to for loops.
Learn until loops in Bash, how they differ from while loops by negating the condition, and how to convert a script from while to until.
Learn to traverse Bash arrays with for loops, using range or list style to print elements such as the first ten prime numbers, or arrays of users, files, and servers.
Explore break and continue as bash loop control statements, learning how break exits a loop when a condition is met and how continue skips an iteration to print odd numbers.
Learn how infinite loops work in bash, when they are useful in rare cases, and how to avoid mistakes in for and while loops by incrementing or decrementing loop counters.
Learn how to create and use bash functions to reuse code, return values, pass arguments, manage local and global variables, and even build recursive functions.
Explore how Bash functions do not return values; they yield the exit status of the last command, and how the return statement can alter that status.
Learn how bash local and global variables differ in scope, with locals limited to a function and globals accessible throughout the script, including updating globals inside a function.
Explore recursion in bash by defining a function that calls itself until a base condition halts the chain, illustrated with factorial and fibonacci examples.
Bash Scripting comes up in almost every single DevOps Interview questions ... Be Prepared!
This course also include my 3 bestseller books (in eBook version):
Learn Bash Quickly
Learn Linux Quickly
Learn Ansible Quickly (RHCE)
Master Bash Scripting and learn how to automate boring administrative Linux tasks.
Key Features
Create and run efficient Bash scripts
Implement Bash functions
Automate complex and repetitive tasks
Course Description
Learn Bash Quickly is a fully practical hands-on course for learning bash scripting. It will get you up and running with bash scripting in no time.
First, you will break the ice with Bash scripting by creating and running a very simple "Hello World" program. Then, you will dive into the world of Bash variables, arguments, string, and arrays. Also, you will learn how to use conditional statements in your bash script. Moreover, you will explore various Bash looping constructs and get to realize how powerful they are. In addition, you will get to write Bash functions, so your code looks clean and unrepetitive. Finally, you will see how you can use bash to automate some of the tedious tasks on Linux.
By the end of this course, you will have all the skills necessarily to develop state of the art bash scripts that can automate any repetitive task you may encounter while working on Linux systems.
What you will learn
Understand how to work with Bash variables, arguments, string, and arrays.
Make your Bash scripts smarter with conditional statements.
Analyze various Bash looping constructs.
Design and create recursive Bash functions.
Automate boring administrative tasks.
Who This Course Is For
If you are tired of spending countless hours doing the same tedious task on Linux over and over again then this course is for you! Learn Bash Quickly will teach you all the skills you need to automate borings tasks in Linux. You will be much more efficient working on Linux after taking this course, more importantly, you will get more sleep, I promise you!
Learn Bash Quickly does assume prior Linux knowledge and that you have experience working on the Linux command line.
Table of Contents
Hello World
Bash Variables
Bash Script Arguments
Bash Arrays
Basic Arithmetic Operations
Bash Strings
Decision Making in Bash
Bash Loops
Bash Functions
Automation with Bash
Solutions to Bash Exercises