Basic Linux Shell Scripting for DevOps!

Getting Started with Linux Shell.

Basic Linux Shell Scripting for DevOps!

What is Shell Scripting?

A shell script is a computer program designed to be run by a Unix shell, a command-line interpreter. The various dialects of shell scripts are considered to be scripting languages. Typical operations performed by shell scripts include file manipulation, program execution, and printing text.

Shell Script example

Shell Script example

What is #!/bin/bash&#!/bin/sh?

#!/bin/bash and #!/bin/sh are called "Shebangs".

#!/bin/bash specifies that the script should be interpreted and executed using the Bash shell (Bourne Again Shell). Bash is a popular and feature-rich shell commonly found on Linux and Unix-based systems. When you use #!/bin/bash as the shebang, you can take advantage of all the advanced features and functionalities that Bash offers.

#!/bin/sh specifies that the script should be interpreted and executed using the default shell of the system. On most Linux and Unix systems, this points to the Bourne shell (sh), or a compatible shell such as the POSIX-compliant shell.

A Shell Script example that prints I will complete #90DaysOofDevOps challenge :

Example

A Shell Script example to take user input, input from arguments and print the variables:

Input from arguments and print the variables

An Example of If else in Shell Scripting by comparing two numbers:

If else in Shell Scripting by comparing two numbers