Day 4 : Basic Linux Shell Scripting for DevOps Engineer

Hi, I am Saad, an aspiring DevOps Engineer. My specialization and career interest lie in DevOps and Cloud Computing. I have a deep interest in automating post-development processes with innovative tools and methodologies. I'm always eager to explore and adopt new technologies in DevOps that can help streamline workflows and optimize performance.
Today, we have the some tasks based on Basic Shell Scripting. Let's solve them together.
Task 1 : Explain in your own words and with examples what Shell Scripting means for DevOps ?
—> Shell scripting consists of a series of commands executed in a shell to perform specific tasks, either once or repeatedly. In the context of DevOps, shell scripting plays a crucial role. It can be used to automate various tasks such as software deployment, testing, backup, and recovery.
Examples of shell scripting include:
Automating File Backup: A script that automatically backs up important files at scheduled intervals.
Disk Usage Check: A script that checks the available disk space and alerts when it falls below a certain threshold.
Server Health Checkup: A script that monitors server performance metrics and sends notifications if any parameters exceed predefined limits.
Task 2 : What is #!/bin/bash ? Can we write #!/bin/sh as well ?
—> #!/bin/bash: This line is known as the shebang. It is the initial command line in a script that indicates the file is a bash script. It tells the system which interpreter to use to execute the script.
Yes, we can use #!/bin/sh as well. The sh shell is a simpler, portable version of other shells like Bash, ensuring that your script can run across multiple platforms with minimal changes.
Task 3 : Write a Shell Script that prints “I will complete #90DaysOfDevOps challenge”.
—> First of all we make a bash file “demo.sh” using vim vim demo.sh . Now we will write commands in this file to display the task.

After saving file, we will give execution permission to the file using chmod 700 demo.sh then we will execute the file by writing ./demo.sh .

Task 4 : Write a Shell Script that takes user input, input from arguments, and prints the variables.
—> To take input from user we use read command and store the input in name variable

give execution permission by chmod +x and execute the file ./demo.sh

Task 5 : Provide an example of an If-Else statement in Shell Scripting by comparing two numbers.
—> To compare two numbers, we can use an if-else statement in a script. Here’s an example:

Then we give execution permission chmod +x demo.sh and execute it ./demo.sh

Here we have completed a little task with the help of basic shell commands. We will continue learning more in the future, so stay connected and keep learning something new every day.






