Table of contents
- Introduction π
- 1. What is Shell? π
- 2. What is Shell Scripting for DevOps? π§ββοΈπ‘
- 3. What is #!/bin/bash? ππ
- 4. Can we write #!/bin/sh as well? π€π
- 5. Shell Script which prints the text "I will complete #90DaysOfDevOps challenge" π―π
- 6. Shell Script to Take Input from Arguments and Print Variables π¨π
- 7. Shell Script with If-Else (e.g Comparing Two Numbers) ππ
- Conclusion ππ
Introduction π
In the world of creating and improving software, teamwork and smooth cooperation are the secret ingredients to success. That's where DevOps comes in! π§β¨ In this blog, we'll explore the amazing world of DevOps, enhanced by the powerful tool called Shell Scripting! π»π
1. What is Shell? π
In the exciting realm of computer interfaces, the Shell is like a friendly tour guide! ππ It's a way for us to talk to the computer using simple commands and scripts. π£οΈπ»
2. What is Shell Scripting for DevOps? π§ββοΈπ‘
Before we delve into mystical script crafting, let's understand what Shell Scripting truly is. It's like having a magical spellbook for automating tasks on your computer! ππͺ These scripts are powerful tools that make repetitive tasks vanish, leaving you with more time to focus on innovation. π©π
3. What is #!/bin/bash? ππ
In the land of scripts, #!/bin/bash is like an invocation spell! π§ββοΈπ It tells the computer that the script should be interpreted and executed using the "bash" shell, which is one of the most popular and versatile shells. ππ»
4. Can we write #!/bin/sh as well? π€π
Indeed, we can! #!/bin/sh is like an open invitation to a universal party! ππ It specifies that the script should be executed using the system's default shell. This means the script can run on various systems without worrying about which specific shell is available. ππ
5. Shell Script which prints the text "I will complete #90DaysOfDevOps challenge" π―π
The echo
command is used to display the specified message on the terminal.
6. Shell Script to Take Input from Arguments and Print Variables π¨π
A) User input :
Output after taking the input:
B) Taking input from arguments:
Output after taking input from arguments:
7. Shell Script with If-Else (e.g Comparing Two Numbers) ππ
Here's an example of using an if-else statement in a shell script to compare two numbers:
User input :
Output after taking the input:
In this example, we have two variables num1 and num2 assigned with the values 4 and 5, respectively.
The if-elif-else construct compares the two numbers using the appropriate comparison operators and prints the corresponding message based on the result.
Conclusion ππ
Congratulations on embracing the magic of Shell Scripting in the DevOps world! π©π» You've learned to create spells that automate tasks, save time, and make you a true DevOps sorcerer! π§ββοΈπ Embrace your newfound power and continue exploring the realm of DevOps with confidence! π§β¨ May your journey be filled with excitement and success! ππ