Learn bash or shell programming for Linux, Unix, and Mac.
If you want to learn how to write bash scripts like a pro, solve real-world problems, or automate repetitive and complex tasks, then this course is for you. You will learn a lot and create bash scripts with ease once you finish this course.
You’ll learn how to take tedious tasks and turn them into programs that will save your time and simplify your life on Linux, Unix, or MAC systems.
If you are new here, please subscribe to my YouTube Channel! https://bit.ly/3AGYyaZ
What is a shell?
The shell is the operating system’s CLI, and interpreter for the set of commands, that are used to communicate with the operating system.
That means, when you run any command on the terminal, the shell interpreter is the one who takes your instructions and talks to the operating system to execute them.
What is bash?
Bash is the improved version of the shell with more functionality such as, array, dictionary, input-output redirection, brace expansion, wildcards, to name a few.
What is bash scripting?
Any series of commands to be executed in the terminal, can be put into a Bash script, and the script may include functions, variables, comments, and etc, and then you can run the script instead of running a series of commands.
Before going ahead, please make sure you have at least bash
v4.0 or above otherwise few commands will never work.
To check how many interpreters your system is currently running.
1 2 3 type -a bash # /usr/local/bin/bash # /bin/bash
To check which bash version your system is using by default. You 3 best to options among others.
1 2 3 /usr/local/bin/bash --version /bin/bash --version /usr/bin/env bash --version
To check which bash path your system is currently running.
1 which bash
To install the latest version if you don’t have a bash
v4.0 or above. otherwise, you can skip this section and read the next topic.
Install Latest Version
1 2 3 sudo apt install bash # Debian, Ubuntu, Mint sudo yum install bash # RedHate, CentOS sudo dnf install bash # Fedora
Don’t forget to install Homebrew package manager if you don’t have one.
1 brew install --cask bash
Don’t forget to install choco package manager if you don’t have one.
1 choco install bash
- Brace Expansion
- String Slicing & Substitution
- Input/Output & Error Redirection
- Execute Multiple Commands at Once
- Shebang Line
- Input from User
- Arithmetic Operators
- Conditional Statements
- Non-Positional/Positional Arguments
- File Importing
- Fatal, Warning, Success, and Info Color Codes
- Write Your Own Command
- SED Command
- CURL Command
- JQ Command
- TR Command
- GREP Command
- CUT Command
- AWK Command
- OpenSSL Command
- Log Rotations
- Cron Job
- Vagrant Command
- Cheatsheets for Bash Scripting