Bash – Arithmetic Operations

Bash Arithmetic Operations You can perform arithmetic operations on numeric values in bash scripts. You can find many options to perform arithmetic operations on bash shell but below example will provide you simplest way. Syntax: ((expression)) ((var1+var2)) ((var1-var2)) ((var1*var2)) ((var1/var2)) Bash Arithmetic Operations Example: For example, take an input of two numeric values and perform all 5 basic arithmetic operations like below:

Increment and Decrement Operator: Bash also used incremnt (++) and decrement (–) operators. Both uses in two types pre-increment/post-increment and pre-decrement/post-decrement.

Similarly, try pre-decrement and post-decrement…

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

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