Concatenate Two Strings

Shell Script to Concatenate Two Strings Brief: This example will help you to concatenate two or more strings variable in a bash script. This tutorial helps you with multiple shell script examples of concatenating strings in a shell script. The first example is a general way to concatenate variables of string. You can simply write all the variable one after another:

Output: Welcome TecAdmin! Another Example You can also use += operator to concatenate two strings and store results in the first string.

Output: Welcome TecAdmin! One More…

Read More

Check if two strings are equal?

Bash – Check If Two Strings are Equal Brief: This example will help you to understand to check if two strings are equal in a bash script. This shell script accepts two string in variables and checks if they are identical. Details Use == operator with bash if statement to check if two strings are equal. You can also use != to check if two string are not equal. You must use single space before and after the == and != operators. Example In this script two variables are initialized…

Read More

Add two numbers?

Shell Script to Add Two Integers Brief: This example will help you to understand to add two numbers in the bash script. This script takes the input of two numbers from the user and prints the sum of both numbers. This is an example script initializes two variables with numeric values. Then perform an addition operation on both values and store results in the third variable.

Command Line Arguments In this second example, shell script reads two numbers as command line parameters and perform the addition operation.


Read More

MongoDB – mongo Shell

What is Mongo Shell? MongoDB provides an interactive mongo shell based on JavaScript. This provides a command line interface between users and MongoDB databases. You can find the best tutorials here for the installation of MongoDB server on Linux operating systems. What is mongo Shell? Mongo shell is a command line interface between user and database. You can connect to your MongoDB server using this shell and manage your databases and collections. You can also perform the administrative tasks on MongoDB. Connect to MongoDB Shell Type mongo on your system…

Read More

Bash – For Loop

For Loop in Bash In a programming language, a loop is used to repeat the execution of a block of code until the satisfied defined condition. Which is helpful to perform repetitive tasks. Mainly there are 3 types of loops, for, do, and do-while. In this tutorial, we will discuss for loop in shell scripting. The shell scripting also provides for loops to perform repetitive tasks. A basic for loop syntax looks like: Syntax: for VARIABLE in PARAM1 PARAM2 PARAM3 do //for-loop statements done The for loop executes for all…

Read More

Bash – Quotes

Quotes in Bash This is a standard practice to quote the string in any programming language. Quotes are used to deal with the texts, filenames with a space character. Read this tutorial to understand the differences between single quote and double quotes. Quote with String While working with simple texts and string, there are no different in using a single quote or double quote.

The above script will run without any error and print the messages and create both directories. Quote with Variables Just remember that the shell variable…

Read More

Bash – Variables

Variables in Bash The bash variables are the same as other programming languages. You don’t need to specify the type of variable in bash scripting. Read below example. #!/bin/bash NAME=”TecAdmin Tutorials” echo $NAME launchdate=”Feb 08, 2013″ echo $launchdate Global vs Local Variables Global variables are accessible anywhere in the script. Where Local variables are accessible in scope only. For example, a variable that is used inside a function only.

System Variables System variables are responsible to define the aspects of the shell. These variables are maintained by bash itself.…

Read More

Bash Tutorial

Shell scripting

Shell Scripting The Bash (Born Again) is a Unix shell and command line language written by the Brian Fox. The Born Again shell is used by most of the Unix/Linux operating systems as there default shell. This Shell Script tutorial is written for the peoples want to learn the basics of shell script programming (Shell scripting). In this series of tutorials, you will learn about bash scripting, which is very useful for automating the daily tasks, larger tasks easier. It helps to automation of tasks like backups, disk cleanup etc.

Read More