Basic Linux Shell Scripting for DevOps Engineers.

Explain in your own words and examples, what is Shell Scripting for DevOps.

Shell scripting is a scripting language, which is interactive means they accept the command as input and executes them. A shell is a command-line interpreter and typical operations performed by shell scripts include file manipulation, program execution, and printing text.

Example:-

#!/bin/bash
#Author: Neha Bisen
#date:18/07/2023
#Purpose: This script will print some statement on terminal


echo "Hello Everyone, Have A Good Day"

What is #!/bin/bash? can we write #!/bin/sh as well?

#!/bin/bash is a shebang that gives instructions to the operating system to use bash as a command interpreter.

Yes, we can write #!/bin/sh also this operating system uses a sh shell as a command interpreter.


Write a Shell Script that prints I will complete #90DaysOofDevOps challenge

#!/bin/bash
echo "I will complete 90DaysofDevops Challenge"

Write a Shell Script to take user input, input from arguments and print the variables.

#!/bin/bash
#Author: Neha Bisen
#Date: 18/07/2023
#Purpose: This shell script will accept 2 Arguments from user and displays it

#Defining Variables
Arg1=$1
Arg2=$2

#Printing Variables
echo "First argument: $Arg1"
echo "Second argument: $Arg2"

Here,

Arg1, --Variable1

Arg2, --Variable2

Execute it with,

./input.sh Neha Bisen

Write an Example of If else in Shell Scripting by comparing 2 numbers.

#!/bin/bash
#Author: Neha Bisen
#Date: 18/07/2023
#Purpose: This shell script will compare 2 numbers using if else

#Defining Variables
Num1=6
Num2=12

#Comaring Variables
if [ $Num1 -lt $Num2 ]
then
        echo "$Num1 is greater than $Num2"
elif [ $Num1 -eq $Num2 ]
then
        echo "$Num1 is equal to $Num2"
else
        echo "$Num1 is lesser than $Num2"
fi