Bash Tips
A collection of 40 posts

Using Bash Declare: Gateway For Effective Variable Management
The declare built-in allows you to explicitly declare variables in bash scripts with specific attributes and control variable types, scope, and behavior.
· Abhishek Prakash

How to Use Associative Arrays in Bash
Use key value pairs with the associative array feature in Bash. Learn to use it with practical examples.
· Satoshi Nakamoto

Check if Array is Empty in Bash
Here are two methods to check if an array is empty in bash. You check if array size is zero or you check if all the elements of the array form an empty string.
· Satoshi Nakamoto

What is IFS in Bash Scripting?
The IFS in bash comes in handy when you are dealing with a different delimiter than the usual space, tab or newline.
· Helder

Use Read Command to Get User Inputs Into an Array in Bash
Learn how to use the read command to get the user input into an array in bash scripts.
· Sagar Sharma

Using Command Substitution in Bash Shell
Command substitution is an important feature that allows you to store the output of a command into a variable.
· Sagar Sharma

Test Operators in Bash
Get a brief look at all the test operators available in bash.
· Sagar Sharma

Run a Bash Shell Script in Linux Command Line [Beginner's Tip]
Running a bash shell script is quite simple. But you also get to learn about running them in the shell instead of subshell in this tutorial.
· Pranav Krishna

Get Script Directory Location in Bash
Here are a couple of ways of getting the directory location of your bash script inside the bash script.
· Sagar Sharma

Various Ways to Increment or Decrement Counters in Bash
Working with loops in bash? Here are various ways of incrementing and decrementing counters.
· Sagar Sharma

Use While Loop in Bash
Learn to use the while loop in bash with practical examples in this tutorial.
· Sagar Sharma

Using Until Loop in Bash
While for maybe the most popular bash loop, wait until you discover until. Pun intended :)
· Sagar Sharma

Read File Line by Line in Bash
Here are a couple of ways for reading file line by line in the Bash shell.
· Sagar Sharma

Use For Loop With Array in Bash
In this Bash scripting example, learn how to use for loop with arrays.
· Sagar Sharma

Check if Variable is Empty in Bash
Learn various ways to check if a variable is empty in bash.
· Sagar Sharma

Get Array Length in Bash
In this quick bash tip, learn about calculating the array length.
· Sagar Sharma

Appending to Arrays in Bash
In this quick Bash tip, you'll learn about appending to an existing array in bash.
· Sagar Sharma

Using exec Command in Bash Shell Scripts
The exec command in shell scripts is super useful for logging, reading from files and running commands by replacing the current process.
· Sagar Sharma

What is $0 in a Bash Script?
Get familiar with the special variable $0 in Bash and learn its usage.
· Sagar Sharma

Special Variables in Bash Shell Scripting
The bash shell has some special variables that have specific usages and purposes. Learn more about them here.
· Sagar Sharma

Check the Number of Arguments in Bash
Working on a bash script that accepts arguments and you need to count them? Here's how to check the number of arguments supplied to your script.
· Sagar Sharma

Using Brace Expansion in Bash Shell
Brace expansion in the bash shell is a lesser known but an awesome feature. Learn about using them like a Pro Linux user with practical examples.
· Abhishek Prakash

Using test Command in Bash Scripts
Learn to use the test command in bash for testing conditions and making comparisons.
· Abhishek Prakash

Useful Bash Commands You May Not Know About
Here are some lesser known but useful bash commands that will help make the shell scripts you write cleaner and more maintainable.
· Hunter Wittenborn

What is Shebang in Linux Shell Scripting?
The seemingly insignificant #! characters at the beginning of a shell script has a major significance on how your script will be executed.
· Abhishek Prakash

Replacing a Substring With Another String in Bash
Learn how to replace a single or multiple occurrences of a substring inside a string in Bash.
· Avimanyu Bandyopadhyay

Unusual Ways to Use Variables Inside Bash Scripts
You might have used variables in Bash before, but probably not like this.
· Hunter Wittenborn

How to Check if String Contains a Substring in Bash
In this bash string tutorial, you'll learn to check whether a given string contains a substring or not.
· Avimanyu Bandyopadhyay

How to Concatenate Strings in Bash
Learn to concatenate strings in bash shell scripts. You'll also learn to append to existing strings and combine strings and integers.
· Avimanyu Bandyopadhyay

Difference Between Single and Double Quote in Bash Shell
Quotes are an integral part of shell scripting and Linux command but they could often be confusing for new users. This article will demystify quotes for you.
· Abhishek Prakash