Table of contents
- Shell
- Shell Scripting
- 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
- Thanks for reading!
Shell
In DevOps, the term "shell" typically refers to a command-line interface (CLI) or scripting language used for automating tasks and managing system operations in software development and operations (DevOps) environment. A shell is a software program that provides an interface for users to interact with an operating system (OS) by executing commands, managing processes, and manipulating files and directories.
Shells are an essential tool in the DevOps toolkit as they allow for efficient and automated management of various tasks such as deployment, configuration, monitoring, and maintenance of software systems. Shell scripts are often used to automate repetitive tasks, streamline workflows, and enable seamless integration between different DevOps tools and technologies.
Types of Shells :
Bourne Shell
BASH Shell
Korn Shell
CShell
TShell
Z Shell
Shell Scripting
Shell scripting is the process of writing and executing scripts or programs in a shell language to automate tasks and perform system operations. A shell script is a series of commands written in a text file that is interpreted and executed by a shell, which is a command-line interface (CLI) or scripting language.
Shell scripting is a key skill for DevOps practitioners as it enables the automation of tasks such as deployment, configuration management, testing, monitoring, and troubleshooting. Shell scripts can be used to create reusable and scalable automation scripts, integrate different tools and technologies, and provide a consistent and efficient way to manage and operate software systems in a DevOps environment.
What is #!/bin/bash?
Can we write #!/bin/sh
as well?
#!/bin/bash
- The "#!/bin/bash" is called a shebang or hashbang, and it is a special line that is often placed at the beginning of a shell script file in Linux. The shebang tells the system which interpreter or shell should be used to execute the script.
# - It means Sha or Sharp
! - It means Bang
#! - It means Shebang
Write a Shell Script that prints I will complete #90DaysOofDevOps challenge
echo: The "echo" command in Linux is used to display text on the terminal. It is a simple command-line utility that allows you to print messages or variables to the screen.
Write a Shell Script to take user input, input from arguments and print the variables.
In this script, we will first create a shell script using vim command namely input.sh
Then we use the read command that allows a shell script to read input from the user during runtime.
Finally, we use the echo command to print the values of the variables.
Write an Example of If else in Shell Scripting by comparing 2 numbers
Firstly, we will create a script named loop.sh
Now in this script, we will read 2 numbers from the user and we will compare those numbers using the -eq and -gt commands
-gt - It is a comparison operator that can be used in conditional statements in Bash shell scripts to compare two numeric values.
-eq - It is a comparison operator that can be used in conditional statements in Bash to compare two numeric values for equality.
In conclusion, shell scripting is a powerful tool for automating tasks and performing complex operations in Linix-like operating systems. With a basic understanding of shell scripting concepts and syntax, you can create scripts to streamline repetitive tasks, manipulate data, and perform system maintenance.
Thanks for reading!
#devops#90DaysOfDevops#TrainWithShubham
Let's connect on Linkedin - linkedin.com/in/namya-khullar-7b5758200