Variable increment and decrement is fundamental arithmetic operation in bash scripting. It’s mostly used with the for, while and until loops. Increment means adding value to variable and Decrement means subtracting from numeric variable value. This article explains multiple ways to increment or decrement a variable. Use of + and – Operators# You must use
terminal - Page 3 of 13 - DesignLinux
How to Check if a String Contains a Substring in Bash
While you working with string in Bash need to check whether a string contains another string. In this guide, we will show you multiple ways to check if a string contains a substring in bash scripting. Use Wildcards# It is easy to use asterisk wildcard symbols (asterisk) * to compare with the string. Wildcard is
Bash Arrays
Arrays are set of data and fundamental requirement for any programming language. We can say that it’s a variable with multiple child variables. This article shows you basics and use of arrays in Bash scripts. Bash Arrays# One dimensional array with numbered index and associative array types supported in Bash. Those are referenced using integers
who Command in Linux
In this article, we explain the who command that is bundled in GNU coreutils package. who is a command-line utility that prints a list of currently logged in users. It can also show the current run level, time of the last system boot, and more. How to Use the who Command # The basic syntax
How to Read a File Line By Line in Bash
At the time of writing of Bash scripts, sometimes you need to read a file line by line. In this tutorial, we will show you how to read file line by line in Bash. Syntax for Read File Line by Line# The following is the common syntax for reading a file line-by-line: while IFS= read
Bash Heredoc
A Heredoc (Here document) is a redirection type which allows to pass multiline lines of input to a command. Sometimes while writing shell scripts you need to pass multiline block of code or text with the command like cat, sftp or tee. In this guide, you will learn how to use the Heredoc in bash.
Bash Concatenate Strings
In any programming language the concatenation is the commonly used string operations. String concatenate is used to joining the two or more strings together by appending one to end of another string. In this tutorial, you will learn how to concatenate strings in Bash. Concatenating Strings# It’s very easy to concatenate multiple string variables by
Bash until Loop
Loops are primary requirement of any programming languages. Loops are useful when you want to execute a series of commands until the certain condition is satisfied. In Bash, loops are useful for automating repetitive tasks. There are three basic loops for loop, while loop , and until loop. In this tutorial, we will see basics
Bash Functions
A Bash function is a predefined set of commands and can be use n number of times. It is useful to avoid repeatedly writing same code. In this tutorial, we will show you the basics of Bash functions. Create Bash Functions# It is very easy and straightforward to create a bash function. You can declare
How to Create Bash Aliases
Bash aliases are shortcuts for the long commands. It allows you to set a memorable shortcut command for a longer command. This guide explains how to create bash aliases on Linux system. Creating Bash Aliases# It is very easy to create bash aliases. Following is the general syntax: alias alias_name=”command_to_run” You should put the alias