Concatenate string variables

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 Example Use another example with one…

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 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. But…

Read More