Tasks
Explain in your own words and examples, what is Shell Scripting for DevOps.
What is
#!/bin/bash?
can we write#!/bin/sh
as well?Write a Shell Script that prints
I will complete #90DaysOofDevOps challenge
Write a Shell Script to take user input, input from arguments and print the variables.
Write an Example of If else in Shell Scripting by comparing 2 numbers
(1) What is Kernel
In computer science, Kernel is a computer program that is a core or heart of an operating system. Before discussing kernel in detail, let's first understand its basic, i.e., Operating system in a computer.
Functions of a Kernel
Device Management
Memory Management
Resource Management
Accessing Computer Resources
(2) What is Shell
A Shell provides you with an interface to the Unix system. It gathers input from you and executes programs based on that input. When a program finishes executing, it displays that program's output.
Shell is an environment in which we can run our commands, programs, and shell scripts. There are different flavors of a shell, just as there are different flavors of operating systems. Each flavor of shell has its own set of recognized commands and functions.
Shell Types
In Unix, there are two major types of shells −
Bourne shell − If you are using a Bourne-type shell, the $ character is the default prompt.
C shell − If you are using a C-type shell, the % character is the default prompt.
The Bourne Shell has the following subcategories −
Bourne shell (sh)
Korn shell (ksh)
Bourne Again shell (bash)
POSIX shell (sh)
The different C-type shells follow −
C shell (csh)
TENEX/TOPS C shell (tcsh)
(3) What is Linux Shell Scripting?
Shell scripting is the process of writing scripts or programs using a shell, which is a command-line interpreter that allows you to execute commands and scripts. It's a scripting language used for automating tasks on a Unix/Linux system, particularly in DevOps, where it can be used for tasks such as deployment, monitoring, and infrastructure management.
The "#!/bin/bash" line at the top of a script tells the system that the script should be interpreted using the bash shell, which is the default shell on most Unix/Linux systems. You can also use other shells such as "#!/bin/sh" for Bourne shell or "#!/usr/bin/env bash" to locate the bash interpreter on the system.
Task
* Write a Shell Script that prints I will complete #90DaysOofDevOps challenge
#!/bin/bash
echo "I will complete #90DaysOfDevOps challenge"
$ I will complete #90DaysOfDevOps challenge
\Write a Shell Script to take user input, input from arguments and print the variables.*
#!/bin/bash
echo "Enter your name:"
read name
echo "Hello, $name!"
*Write an Example of If else in Shell Scripting by comparing 2 numbers
#!/bin/bash
num1=10
num2=20
if [ $num1 -gt $num2 ]
then
echo "$num1 is greater than $num2"
else
echo "$num2 is greater than $num1"
fi