Table of contents
No headings in the article.
Hi Friends,
In this blog, we are going to discuss shell scripting basics and why it is important for a DevOps Engineer.
What is Shell Scripting for DevOps?
Before moving to Shell scripting Let's understand what is shell and its types.
The shell acts as an interface between the user and the kernel. It reads commands provided by the user and checks whether the command is valid or not or properly used or not.
if the command is proper or the syntax is correct then the shell converts it into kernel understandable and gives it to the kernel. The kernel will execute that command with the help of hardware.
We can check the shell in our system by writing the $ echo $0 command or $ echo $SHELL.
Types of Shells :
Bourne Shell
BASH Shell
Korn Shell
CShell
TShell
Z Shell
The most commonly used shell in the Linux environment is BASH Shell. Because it's more powerful than the remaining shells.
What is Shell Script?
The shell script is nothing but a file where multiple commands are written in a sequence to achieve a particular task at a particular time. The shell script is used for automation purposes. Instead of writing the same commands on daily basis writing them down in a file and running them on a particular day and time saves DevOps engineer time. Automation can be anything like taking a backup of a database, Monitoring CPU usage, Getting a notification if server memory is full etc.,
What is
#!/bin/bash?
Can we write#!/bin/sh
as well?Now let's try to understand what is #! /bin/bash.
#=> It means Sha or Sharp or She
! => It means Bang
#! => Shebang or Sha
#!/bin/bash ==> It means the script should be executed by the bash interpreter.
#!/bin/sh ==> It means the script should be executed by the Bourne Shell interpreter.
Write a Shell Script that prints
I will complete #90DaysOofDevOps challenge
echo $0 command is used to check the default shell in the system.
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
Thank You for reading this blog
Parimal Pradhan
You can follow me on LinkedIn for my daily updates:- linkedin.com/in/parimal-pradhan-b62021168
Great initiative by the #trainwithshubham community. Thank you Shubham Londhe
#devops #90daysofdevops