Day 4 : Shell & Shell Scripting in DevOps
What is 'Shell', 'Shell-Scripting' and its uses.
Table of contents
- 🐚What is 'Shell'?
- 📜What is 'Shell Scripting'?
- 📚Tasks:
- 💠What is #!/bin/bash?
- 💠Can we write #!/bin/sh as well?
- 💠Write a Shell Script which prints I will complete the #90DaysOfDevOps 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.
- ✉Endcard:
🐚What is 'Shell'?
A "shell" is like a command interpreter or translator that acts as a connection between you and your computer's operating system. It's an interface where you can communicate with your computer by typing commands, just like talking to a helpful assistant.⚙
Imagine the shell as a language translator. You speak in your language (commands), and the translator (shell) converts your words into a language the computer understands. This enables you to perform various tasks and operations on your computer without using a graphical user interface (GUI).👨💻
It's an efficient and powerful way to interact with your computer, and many professionals use it to automate tasks, manage files, and perform advanced operations.🛠
This is what a CLI (Command Line Interface) can look like. This is where you can talk to the 'Shell' using commands.
📜What is 'Shell Scripting'?
Shell scripting is a way of automating tasks on a computer using simple instructions written in a language called a "shell script." It's like creating a to-do list for your computer to follow and perform tasks automatically.
In this script, you tell the computer what to do step-by-step, such as copying files, renaming folders, or running programs. The computer reads the script, follows your instructions, and completes the tasks without needing your constant input.
Shell scripting saves time, reduces repetitive work, and helps in managing complex tasks efficiently.
🧾Shell Scripting in DevOps
Shell Scripting is a key component of the DevOps toolkit, enabling automation, infrastructure management, troubleshooting, and seamless integration.
📚Tasks:
💠What is #!/bin/bash
?
#!/bin/bash
--> This is called a 'shebang' It is used in scripts to instruct the operating system to use bash as a command interpreter.
💠Can we write #!/bin/sh
as well?
Yes but,
bash
andsh
are two different shells. Basically,bash
issh
with more features and better syntax. Most commands work the same, but they are different.
💠Write a Shell Script which prints I will complete the #90DaysOfDevOps challenge
#!/bin/bash
echo "I Will Complete the #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 "Your name is $name"
💠Write an Example of If else in Shell Scripting by comparing 2 numbers.
#!/bin/bash
#!/bin/bash
a=10
b=25
if [[ $a -lt $b ]]
then
echo "a is less than b"
else
echo "a is greater than b"
fi
#OUTPUT --> 'a is less than b'
✉Endcard:
🎉 Thank you for joining me on this insightful journey into the world of DevOps!
❤ If you found this blog helpful and informative, don't forget to give it a like!
🔄 Share this valuable knowledge with your friends and colleagues, so they can also benefit from understanding the power of DevOps!
👉 Stay updated with my latest posts and never miss out on exciting content! Click that Follow button to join and stay in the loop!
Follow me on Linkedin --> abdallah-qamar 👔
Stay tuned for Day 5...👋
#DevOps #SoftwareDevelopment #Technology #FollowUs #LikeAndShare #StayInformed #90daysofdevops #linux 📚🔍🌈