Day 1 of the Bash Scripting 
               Challenge! ๐Ÿš€ #TWSBashBlazeChallenge

Day 1 of the Bash Scripting Challenge! ๐Ÿš€ #TWSBashBlazeChallenge

โœ’๏ธ Introduction

Hello EveryOne, Today I'm starting a 7 Day's Bash Script Challenge organized by Shubham Londhe . Here every day we will dive into Script, If you are interested in this then you also join this challenge, where you will learn new things.

As we talk about our Day 1 challenge we will be learning about the basics of Bash Script, Without any further discussion we will start.

โœ’๏ธWhat is Bash Script?

Hey there! ๐ŸŽ‰ Imagine you have a magical fairy assistant ๐Ÿงšโ€โ™‚๏ธ that follows your every command! Well, that's kind of what a Bash script is! ๐ŸŒŸ

๐Ÿ’ป Bash is like a wizard ๐Ÿง™โ€โ™‚๏ธ who speaks computer language and can perform amazing spells on your computer! With a Bash script, you give the wizard a list of instructions written in a special language (Bash script), and he magically executes them one by one!

๐Ÿ“ The script is like a recipe ๐Ÿฒ for the wizard. You write down all the steps you want him to follow, like "wave the wand," "mix the potion," and "cast the spell" ๐Ÿช„ - those are your commands!

๐Ÿ” Then, the wizard reads the recipe (your script) line by line, and BOOM! ๐Ÿ’ฅ Your computer starts doing all the cool stuff you asked for! It can create folders, move files, talk to other programs, and so much more!

โœจ And the best part? You can reuse the same magical recipe over and over again to make the wizard perform the same spell! It saves you lots of time and effort! ๐Ÿ•ฐ๏ธ

๐Ÿ’ก So, when you hear about a "Bash script," think of it as a magical spellbook ๐Ÿ“š that lets you control your computer with just a few lines of special wizardry language! ๐Ÿง™โ€โ™€๏ธ๐ŸŒŸ

Task:1 Comments

๐Ÿ“ Imagine you're writing a secret diary ๐Ÿ“”, and you want to add little notes to remind yourself of what's happening in your adventurous journey. Well, that's exactly what comments are in a Bash script! ๐Ÿ’ฌ

๐ŸŒŸ Comments are like hidden messages ๐Ÿ’Œ that you write in your script, meant only for you (and other wizards who read your code). They start with a special symbol, the "hashtag" or "pound sign" (#). It's like casting an invisibility spell on your words, so the computer ignores them completely! ๐Ÿšซ๐Ÿง™โ€โ™‚๏ธ

๐Ÿ—๏ธ So, when you want to remember what a particular part of your script does, or if you want to leave a clue for fellow wizards who might look at your code, you sprinkle these magical hashtags and share your thoughts! It's like leaving breadcrumbs in the enchanted forest of code. ๐ŸŒณ๐Ÿฐ

๐Ÿ” Here's the fascinating part: the spells you write in your script are spoken in the language of computers, but comments are your secret language, meant only for humans to understand! ๐Ÿ—ฃ๏ธ๐Ÿ’ป

๐Ÿ’ญ So, next time you're casting your Bash spells, remember to use the power of comments to keep track of your adventures and guide your fellow wizards through the mystical world of your code! ๐Ÿง™โ€โ™€๏ธ๐ŸŒŒ

#!/bin/bash

# DevOps Engineer: This is a bash script that demonstrates basic concepts of bash scripting.
# Task 1: Comments
# - In this task, we will use comments to explain the script.

# Output a welcome message to the user
echo "Welcome to Day 1 of the Bash Scripting Challenge!"

Task:2 Echo

๐Ÿ—ฃ๏ธ Imagine you're a powerful sorcerer with a magical megaphone ๐Ÿ“ข that can make your voice echo throughout the entire kingdom! Well, that's exactly what the "echo" command does in a Bash script! ๐Ÿง™โ€โ™‚๏ธ๐Ÿ’ฌ

๐Ÿ’ป When you use the "echo" spell in your script, you're casting a charm that makes your words appear on the screen for all to see! It's like leaving sparkly messages ๐Ÿ’Œ that everyone can read, including other wizards and even your computer! ๐Ÿงšโ€โ™€๏ธโœจ

๐ŸŒˆ Just like a fairy spreading fairy dust, "echo" sprinkles your words on the display, creating a magical connection between you and your computer. You can send greetings, share secret incantations, or display the results of your mystical calculations! ๐Ÿ“œ๐Ÿ”ฎ

๐Ÿ“ To cast the "echo" spell, you simply write "echo" followed by the words you want to share. Your computer listens carefully to your commands, and when it encounters "echo," it gleefully displays your message on the screen like a shimmering spell coming to life! ๐Ÿช„โœจ

๐Ÿ’ญ So, when you want to communicate with your computer or let others in on your sorcery, just reach for the "echo" spell, and watch as your words fill the realm of code with wonder and enchantment! ๐Ÿ—๏ธ๐ŸŒŒ

#!/bin/bash

# DevOps Engineer: Task 2: Echo
# - In this task, we will use the 'echo' command to print a message.

# Output a welcome message to the user
echo "Welcome to Day 1 of the Bash Scripting Challenge!"

Task:3 Variables

๐ŸŽญ Imagine you're a clever magician ๐Ÿ”ฎ, and you have a magical box ๐Ÿ“ฆ where you can store all sorts of treasures! Well, in the realm of Bash scripts, that magical box is called a "variable"! ๐ŸŽฉ

๐Ÿง™โ€โ™‚๏ธ Variables are like containers that hold valuable information, just like your magical box holds precious gems and spells! They have unique names, and you can put different things inside them, like numbers, words, or even whole sentences! ๐ŸŒˆ๐Ÿ”ข๐Ÿ—ฃ๏ธ

๐Ÿ” Whenever you need to remember something important during your magical incantations, you can store it in a variable. It's like labeling your potions, so you can easily find them later! โœ‰๏ธ๐Ÿท๏ธ

๐Ÿ“ And here's the exciting part: you can change the contents of your magical box whenever you like! So, if you need a new gemstone or a different spell ingredient, you can swap it out in a snap! ๐Ÿ’Ž๐ŸŒŸ

๐Ÿค Variables are like messengers ๐Ÿƒโ€โ™€๏ธ between your spells. They carry information from one part of your script to another, helping your spells work together harmoniously! It's like having magical assistants who can fetch and deliver things for you! ๐Ÿ“ฌ๐Ÿงšโ€โ™€๏ธ

๐Ÿ’ก So, whether you're counting enchanted stars, storing the name of your magical pet dragon, or keeping track of your quest progress, variables are your trusty companions on this mystical coding adventure! ๐Ÿ‰โœจ

#!/bin/bash

# DevOps Engineer: Task 3: Variables
# - In this task, we will declare and use variables.

# Declare variables and assign values
name="Purushotam"
age=20

# Output the values of variables
echo "Name: $name"
echo "Age: $age"

Task 4: Using Variables

Now that we have declared variables, let's use them to perform a simple task. In this task, we will create a bash script that takes two variables (numbers) as input and prints their sum using those variables.

#!/bin/bash

# DevOps Engineer: Task 4: Using Variables
# - In this task, we will use variables to perform a calculation.

# Get user input for two numbers
read -p "Enter the first number: " num1
read -p "Enter the second number: " num2

# Calculate the sum of the two numbers
sum=$((num1 + num2))

# Output the result
echo "The sum of $num1 and $num2 is: $sum"

Task 5: Using Built-in Variables

Bash provides several built-in variables that hold useful information. Your task is to create a bash script that utilizes at least three different built-in variables to display relevant information.

#!/bin/bash

# DevOps Engineer: Task 5: Using Built-in Variables
# - In this task, we will use built-in variables.

# Output the current user
echo "Current user: $USER"

# Output the hostname
echo "Hostname: $HOSTNAME"

# Output the current working directory
echo "Current directory: $PWD"

Task 6: Wildcards

๐ŸŒŸ Imagine you have a magical key ๐Ÿ”‘ that can unlock countless doors with just one turn. Well, that's precisely what wildcards are in a Bash script! They are like powerful, all-purpose keys that let you unlock and manipulate files and folders in the blink of an eye! ๐Ÿšช๐Ÿ”“

๐Ÿ—๏ธ Wildcards are represented by special characters like the "asterisk" (*) and the "question mark" (?). When you include these mystical symbols in commands, the Bash wizard takes it as a sign to unleash their magic! โœจ๐Ÿง™โ€โ™€๏ธ

๐ŸŒŒ The "asterisk" (*) is like a shooting star ๐ŸŒ  in the night sky. It matches any number of characters, allowing you to find files with mysterious and ever-changing names. It's like having a shape-shifter at your command! ๐ŸŒŸ๐Ÿงžโ€โ™‚๏ธ

๐ŸŒˆ On the other hand, the "question mark" (?) is like a treasure map with missing pieces. It stands for just one unknown character, making it perfect for uncovering hidden files with puzzling names! It's like having a crystal ball to predict the unknown! ๐Ÿ”๐Ÿ”ฎ

๐Ÿฐ With these wildcards, you can conjure spells like "list all the files that start with 's'," or "delete everything ending with '.txt'." Your commands become a symphony of mystery and discovery! ๐ŸŽถ๐ŸŽ‡

๐Ÿ’ก So, when you venture into the world of Bash scripts, don't forget to wield the power of wildcards! They are your trusty companions on this enchanting journey, helping you navigate the vast landscapes of files and directories with ease! ๐Ÿ—บ๏ธ๐Ÿงญ

Conclusion

In the enchanting world of Bash scripting, you have embarked on a magical journey filled with powerful spells and captivating adventures! ๐Ÿง™โ€โ™‚๏ธโœจ

๐Ÿ’ก You learned the secret language of Bash, where variables act as mystical containers, holding the essence of your data and secrets close to your heart! ๐ŸŽ๐Ÿ’–

๐ŸŒŸ Command spells allowed you to wield the power of your computer, bending it to your will with every line you wrote! ๐Ÿš€๐Ÿ–Š๏ธ

๐Ÿƒ Wildcards became your all-purpose keys, unlocking doors to hidden files and folders, revealing the mysteries of the digital realm! ๐Ÿ—๏ธ๐ŸŒŒ

๐Ÿ’ฌ And amidst your spellbinding code, comments became your whispered confidants, guiding you through your own magical incantations and helping fellow wizards comprehend the secrets within! ๐Ÿ“๐Ÿค

๐Ÿง™โ€โ™€๏ธ Now, armed with this newfound knowledge, you can weave your own captivating Bash scripts, orchestrating symphonies of code that dance and sing in harmony! ๐ŸŽถ๐ŸŒˆ

So go forth, young sorcerer, and embrace the beauty of Bash scripting! Let your creativity soar as you conjure up amazing scripts, unlocking the full potential of your computer's magic! ๐Ÿงšโ€โ™‚๏ธ๐ŸŒŸ๐Ÿ”ฎ

Checkout My GitHub Repository for projects:

Thanks for reading this blog. If you like this blog and find helpful then share with your friends. Happy Learning.

Did you find this article valuable?

Support Dev Cloud by becoming a sponsor. Any amount is appreciated!

ย