Skip to main content

Bash Tips

Here is a collection of bash shell scripts that will not only help you learn shell scripting but also improve your existing bash shell knowledge.

A collection of 40 posts

Using Bash Declare
Bash Tips

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

Associative arrays in bash
Bash Tips

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
Bash Tips

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

IFS in bash
Bash Tips

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

Bash: Read Into an Array
Bash Tips

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

Bash command substitution
Bash Tips

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
Bash Tips

Test Operators in Bash

Get a brief look at all the test operators available in bash.

· Sagar Sharma

Run bash shell script in Linux command line
Bash Tips

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 directory location in Bash
Bash Tips

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

Increment decrement counters in Bash
Bash Tips

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

While loop in bash
Bash Tips

Use While Loop in Bash

Learn to use the while loop in bash with practical examples in this tutorial.

· Sagar Sharma

Until loop in bash
Bash Tips

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
Bash Tips

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

For Loop with Array in Bash
Bash Tips

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
Bash Tips

Check if Variable is Empty in Bash

Learn various ways to check if a variable is empty in bash.

· Sagar Sharma

Bash array length
Bash Tips

Get Array Length in Bash

In this quick bash tip, learn about calculating the array length.

· Sagar Sharma

Arrays in bash
Bash Tips

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
Bash Tips

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

$0 in Bash
Bash Tips

What is $0 in a Bash Script?

Get familiar with the special variable $0 in Bash and learn its usage.

· Sagar Sharma

Bash special variables
Bash Tips

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 number of arguments in Bash
Bash Tips

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

Brace expansion in bash shell
Bash Tips

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

bash test command
Bash Tips

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
Bash Tips

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

Shebang in Linux
Explain

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

Replace substring in bash
Bash Tips

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

Bash variable usage
Bash Tips

Unusual Ways to Use Variables Inside Bash Scripts

You might have used variables in Bash before, but probably not like this.

· Hunter Wittenborn

Check if string contains substring
Bash Tips

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

Concatenate strings in bash
Bash Tips

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

Handling quotes in Linux shell scripting
Explain

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