Day 4 Task: Basic Linux Shell Scripting for DevOps Engineers.

Day 4 Task: Basic Linux Shell Scripting for DevOps Engineers.

What is Shell Scripting for DevOps

Shell scripting is a way to automate repetitive tasks or execute a series of commands on a Unix or Linux-based system. It involves creating scripts using the shell, which is the command-line interface (CLI) used in these operating systems. The shell is a powerful tool that allows users to interact with the system and execute various commands, utilities, and scripts.

In the context of DevOps, shell scripting plays a crucial role in automating tasks such as deployment, configuration, and testing of software applications. Shell scripts are often used to automate the process of building and deploying code changes to production environments, running tests, and monitoring system performance.

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

#!/bin/bash is called a "shebang" or "hashbang" and is a special comment line that specifies the interpreter for the script. In this case, it specifies that the script should be run using the Bash shell.

Yes, you can write #!/bin/sh instead, which specifies that the script should be run using the default shell on most Unix-like systems, which is usually a Bourne shell or a compatible shell like Bash or Dash. However, there are some differences in the syntax and features supported by different shells, so you should use the appropriate shebang line for the shell that you are using and for the syntax and features that your script requires.

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

#!/bin/bash

echo "I will complete #90DaysOfDevOps challenge"

Save the script with a .sh extension (e.g. challenge.sh) and make it executable using the command chmod +x challenge.sh. Then, run the script by typing ./challenge.sh in your terminal. The script should output the message "I will complete #90DaysOfDevOps challenge".

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

#!/bin/bash

echo "enter first number: "

read num1

echo "enter second number: "

read num2

if [ $num1 -gt $num2 ]; then

echo "$num1 is greater then $num2."

elif [ $num1 -lt $num2 ]; then

echo "$num1 is less then $num2."

else

echo "$num1 is equal to $num2."

fi

:wq!

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

#!/bin/bash
echo "what is your name"
read name

echo "your name is $name"
:wq!

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

#!/bin/bash

echo "I Will complete #90DaysofDevops Challenge"

:wq!

./print.sh