Bash Tutorial – Learn Bash Shell Scripting

About Bash

Bash is a Unix Shell. Using Bash commands we can write applications for Linux OS.

Bash Script

Bash Script is a file with commands that can be run from Linux Terminal.

Bash Tutorial

With the help of these Bash Shell Scripting tutorials, we shall learn bash scripting. Little understanding of the Linux file system and terminal commands would be helpful to get started with these tutorials.

Bash Tutorial

Bash Scripting Basics

In these series of basic bash tutorials, we shall introduce you to some of the bash fundamentals.

  • TutorialBash Script Example: Explanation about the basic components of a bash script file
  • TutorialBash File Extension: Know about the file extension for a bash script and the syntax required to tell the Operating System that a file is bash script.
  • Tutorial – Echo: Basic Bash Command to echo a string or variables to the terminal.
  • Tutorial – Variables: Variables are used to store data. The tutorial describes bash variables and local bash variables with syntax, usage, and examples.
  • Tutorial – Command Line Arguments: User can pass arguments while running the script file. The tutorial explains how to work with arguments.
  • Tutorial – Read User Input: Taking input from the user is an important aspect for any kind of program/application. Learn to prompt the user for input
  • Tutorial – Read Username and Password: Learn to read password without echoing back the actual password to a Linux terminal.

Bash Operators

  • Bash Operators
  • TutorialBash Arithmetic Operators: Examples and Usage demonstration of arithmetic operators in bash scripting.
  • Bash Relational Operators
  • Bash Conditional Operators

Bash Conditional Statements

Conditional Statements help to branch out the program execution based on the value of an expression. Following are some of the bash tutorials that provide a broad understanding of conditional statements that can be used in bash scripting.

  • Tutorial – Bash If Statement: Introduction to conditional statements with if statement. Contains syntax and examples.
  • TutorialBash If-Else Statement: Going a step deeper into two-level branching of program control.
  • Tutorial – Bash Else-If Statement: Mulitple branching conditions in a single statement.
  • TutorialBash Case Statement: Executing a specific set of statements based on the value of a variable or an expression.

Bash Loops

  • Tutorial – Bash For Loop: For Loop statement helps to execute a set of statements for each member of a data set or a derived data type variable.
  • Tutorial – Bash While Loop: Repeat a set of statements based on an expression.
  • Tutorial – Bash Until Loop: This is a little variation to while loop, but it is handy.

Bash Strings

  • TutorialBash String Manipulations: Some of the commonly used string operations with examples.
  • TutorialBash String Length: Find the length of a given string.
  • TutorialBash Strings Equal: To check if given two strings are the same in value or not.
  • TutorialBash Split String: Split a string into tokens based on a single character delimiter or another string as a delimiter.
  • TutorialBash Sub-String: Get the substring of a string when starting and ending index are given.
  • TutorialBash Concatenate Strings: Learn to concatenate two or more strings.

Bash Functions

Functions help to wrap a logical piece of a task as a functionality that could be called.

  • TutorialBash Functions: A basic introduction to functions in Bash Scripting.
  • TutorialBash Override Commands: This is interesting. You can override the built-in commands with your own set of statements.

Bash Arrays

Arrays are used to store multiple elements in a single container. Elements can be accessed using the index.

  • TutorialBash Array: A decent introduction to initialize an array and access elements of it in bash scripting.

Bash File Operations

  • TutorialBash Read File: Example bash scripts to read contents of a file.
  • TutorialBash Read File Line by Line: Example bash scripts to read contents of a file (like text file) line by line.
  • TutorialBash Write to File: Example bash scripts to write data to a file.
  • Tutorial – Check if the file exists: Bash script to check if the file exists.
  • Tutorial – Check if the file is a directory: Bash script to check if the file is a directory.
  • Tutorial – Check if the file is readable: Bash script to check if the file is readable.