Recommended Reading
How to Parse a CSV File in Bash?
Learn how to parse a CSV file in Bash and avoid the common pitfalls. Includes examples using bash builtins and the awk command line.
5 Mistakes To Avoid For Writing High-Quality Bash Comments
Adding comments in your Bash scripts is necessary to ensure maintainability over time. This post covers 5 Bash comments mistakes to avoid in your shell scripts.
How to do Math in Bash
Math Arithmetic: How To Do Calculation in Bash?
Learn how to do math arithmetic with integer and floating-point in Bash. Includes addition, subtraction, division, multiplication, and also floating-point precision.
How To Do Advanced Math Calculation Using bc?
Learn how to use the GNU Linux bc command line to do math arithmetic and algebra with square root, sine, cosine, tangent, arctangent, bessel, and more.
Bash Guides & Tutorials
A Complete Guide on How To Use Bash Arrays
This guide covers how to use the bash array variables as indexed or associative bash arrays. Includes how to declare, iterate over, sort, and other array operations.
What is the Right Way to do Bash Loops?
Looping over a list of numbers or words is a building block in shell scripts. Learn how to write Bash loops, including for loop, while loop, and until loop.
All Mastering Bash with Tips and Tricks
How to Use Bash Loadable Builtins with enable -f
Learn how to compile and load C shared libraries directly into a running Bash shell process using the enable -f builtin command.
How to Check, Lint, Format, and Test a Bash Script
How to check syntax, lint, format, and test Bash scripts with bash -n, ShellCheck, shfmt, and Bats, including the exact flags for each tool.
How to Master String Pattern Matching using Bash Character Classes
Exploring the power of GNU bash character classes for efficient pattern matching in regular expressions, with an example script to generate an ASCII table.
Top 10 Bash Pitfalls You Don't Want to Make
This blog post provides an informative guide to common pitfalls in GNU Bash shell and offers practical tips and solutions for avoiding or resolving them.
5 Simple Steps On How To Debug a Bash Shell Script
Learn how to quickly debug scripts in Bash with those 5 simple steps that use some of the Bash shell special properties.
A Complete Guide to the Bash Environment Variables
A complete guide on the Linux Bash environment variables with details on how to set, unset, and use the specials shell variables or define custom environment variables.
How To Make A Custom Bash Shell Prompt
Learn how to customize your shell prompt and the specificity of the Bash Prompt variables PROMPT_COMMAND, PROMPT_DIRTRIM, PS0, PS1, PS2, PS3, and PS4.
The Most Useful Bash Shortcuts That You Will Want To Use
A detailed review of the most useful Terminal and Bash shortcuts to improve your productivity when typing command-lines and how to customize the ones you don't like.
The Complete How To Guide of Bash Functions
Learn how to write shell scripts with bash functions. This guide includes examples and best practices on how to define, call, and debug functions in bash.
How To Create Simple Menu with the Shell Select Loop?
The select loop is not a regular shell loop. It can be used in Bash to generate a simple menu from which a user can select numbered options.
What is the Right Way to do Bash Loops?
Looping over a list of numbers or words is a building block in shell scripts. Learn how to write Bash loops, including for loop, while loop, and until loop.
5 Mistakes To Avoid For Writing High-Quality Bash Comments
Adding comments in your Bash scripts is necessary to ensure maintainability over time. This post covers 5 Bash comments mistakes to avoid in your shell scripts.
How To Script Error Free Bash If Statement?
Learn how to script a Bash If statement with the then, else, and else if / elif clauses. Includes Bash conditional expressions and common pitfalls to avoid.
What is the Bash Null Command?
Learn about the Bash null command, also known as the POSIX shell colon command. This post cover concrete use cases and pitfalls to avoid.
How and When to Use the Dot Command in Bash?
Learn the difference between the dot command (.) and a dot file notation. This post cover how and when you should leverage the dot command to execute a Bash script.
How to Parse a CSV File in Bash?
Learn how to parse a CSV file in Bash and avoid the common pitfalls. Includes examples using bash builtins and the awk command line.
Bash Error: Must Use Subscript When Assigning Associative Array
How to solve the Bash Error "must use subscript when assigning associative array". This post covers why it is occurring and how to fix the error when using Bash arrays.
A Complete Guide on How To Use Bash Arrays
This guide covers how to use the bash array variables as indexed or associative bash arrays. Includes how to declare, iterate over, sort, and other array operations.
What's New in GNU Bash 5?
Bash version 5 is generally available and comes with some important improvements and new features like BASH_ARGV0, EPOCHSECONDS, and EPOCHREALTIME.
Download files from a Bash Shell
Introduction to the essential function of downloading files directly from a Bash script. This is a common task in any kind of backup/restore automation or in crawling scenarios to retried some kind of data on a regular basis.
Math Arithmetic: How To Do Calculation in Bash?
Learn how to do math arithmetic with integer and floating-point in Bash. Includes addition, subtraction, division, multiplication, and also floating-point precision.
How To Generate Sequences of Letters or Numbers?
Learn how to use seq command line and the bash braces expansion to generate sequences of letters or numbers in your shell scripts.
A Quick Guide on How to Use Bash Alias
This post cover the Bash builtin commands alias and unalias. You will often find Bash alias in a customized .bashrc to improve your shell command-line workflow.
How To Use Bash Wildcards for Globbing?
Improve your productivity at the Linux command line and in Bash scripting with globbing by using Wildcards as glob patterns or extended glob expressions.
How To Find Quickly A Bash Command Type?
Learn how to find out the type of a shell command and the definition of an alias or function by using the type or command Bash builtins.
GNU Bash, sometimes referred to as Linux Bash or just Bash, is the GNU project’s command-line shell and a complete implementation of the IEEE POSIX shell specification. Brian Fox wrote the first version for the GNU Project in 1989, and it has been the default shell on most Linux distributions ever since. It is still the shell that most scripts in the wild are written against, including the ones you inherit.
Bash is two things at once, which is where a lot of the confusion starts. Interactively it is a prompt: you type a command and read its output. In a script it is a programming language, with variables, arrays, functions, conditionals, loops, and arithmetic — along with its own sharp edges around quoting, word splitting, and subshells. Syntax that behaves at the prompt is often the same syntax that fails silently in a script months later, which is why debugging and commenting matter more here than the size of a script suggests.
Open a terminal — Ctrl+Alt+T on most Linux desktops — and these are the commands you reach for first:
cd,ls,mkdir— move around the filesystem, list it, add to itcp,mv,rm— copy, move, and delete files and directoriesgrep— find a pattern in a file or in a streamsed— substitute and transform text as it passes throughawk— process text one record and one field at a timeps,top— see which processes are running and what they cost
Tab completes command names and file names. It is the first habit
worth building, and the help builtin covers everything Bash implements itself.
Bash is not only on Linux. macOS still ships Bash 3.2 as /bin/bash and
defaults to zsh, so
upgrade it before relying on
associative arrays or anything else added since. On Windows,
WSL runs a
real distribution with a real Bash.
Version 5 added EPOCHSECONDS and
EPOCHREALTIME, BASH_ARGV0, saner [a-z] range matching, and a long list of
fixes worth having.
