The DevOps Engineer's Guide to Basic Linux Shell Scripting🌟👩💻

Finding Way to the Cloud.
👉Introduction: 🌟
Imagine having a very obedient assistant who can perform a variety of jobs for you and who will listen to all of your instructions. Now when you need to speak with this assistant, you must do so in their single language of understanding. In the world of computers, the "assistant" is known as the "shell," and the language it speaks is known as the "shell scripting language."
👉What is Shell?
A shell is a specialized user program that offers an interface for users to use the services of the operating system. Shell accepts user commands that are human-readable and converts them into terms that the kernel can comprehend. It is a command language translator that carries out commands that are read from files or input devices like keyboards and others. When a user logs in or opens a terminal, the shell launches.
👉What is Linux 🐧 Shell Scripting💻?
A command-line interpreter, or "shell," is a type of computer program made to be used by Linux. Scripting languages are seen as including numerous varieties of shell scripts. Text printing, program execution, and file manipulation are among the frequent tasks carried out by shell scripts.
👉Why Use Shell Scripting in DevOps? 🛠️
Automation: Shell scripts streamline repetitive tasks, saving time and reducing human errors and efforts.
Cross-Platform: Shell scripts can be used across different operating systems with minor modifications.
Integration: Easily integrate shell scripts with other DevOps tools and workflows.
👉Real-World Scenarios and Use Cases 🌐
Automated Deployments: Deploying software to servers automatically.
Making scripts for automatic backup and recovery procedures is part of backup and restoration.
Log analysis is the process of extracting crucial information from logs and producing reports.
Shell script integration in CI/CD pipelines for build and deployment operations is known as continuous integration (CI).
Shell scripts can be used to programmatically generate and manage cloud resources through infrastructure provisioning.
👉Let us illustrate the simplicity and power of shell scripting..🚀🚀
What is #!/bin/bash? can we write #!/bin/sh as well?
🐚
#!/bin/bash: This is referred to as the "shebang" or "hashbang." The first line of a shell script specifies which shell should read the script, informing the computer which shell to use. In this instance, it specifies using the "bash" shell to run the script. 🚀🤔 Can we write
#!/bin/shas well? Yes, absolutely! The#!/bin/shshebang is also commonly used and instructs the computer to use the default shell (usually "sh") to interpret the script. It's a more generic approach, as "sh" is available on most Unix-like systems.So, both shebangs
#!/bin/bashand#!/bin/share commonly used in shell scripting. 🌟
👩💻Write a Shell Script that prints "I will complete #90DaysOofDevOps challenge"

In this script, the shebang (#!/bin/bash) specifies the interpreter to be used (Bash, in this case). The echo command is used to display the specified message on the terminal.
👩💻Write a Shell Script to take user input, input from arguments, and print the variables
🌟Script to take user input.

🌟Output after taking the input.

🌟Taking input from arguments.

🌟Output after taking input from arguments.

👩💻Write an Example of 'If else' in Shell Scripting by comparing 2 numbers.


🌟In this script, we take the inputs from the user to the variables 'num1' and 'num2'. The if-elif-else construct compares the two numbers using the appropriate comparison operators and prints the corresponding message based on the result.
Comparison Operators 🟰< >
Comparison operators are used within conditional statements to evaluate conditions. Here are some commonly used comparison operators in shell scripting:
Operator | Description |
-eq | Equal to |
-ne | Not equal to |
-gt | Greater than |
-lt | Less than |
-ge | Greater than or equal to |
-le | Less than or equal to |
! | Logical NOT |
-z | Empty string |
-n | Non-empty string |
Many more concepts to come🎓🚀🤝
Conclusion: 🏁
A crucial skill for any DevOps engineer is shell scripting. In the world of DevOps, its capacity to automate jobs, streamline procedures, and interface with other tools makes it indispensable. You may advance your automation abilities and become a skilled DevOps practitioner by understanding shell scripting. So get ready to roll up your sleeves, work hard at practice, and explore the exciting world of DevOps while learning all there is to know about shell programming!🚀🔥



