Day 8 Task: Shell Scripting Challenge

Hi, I’m Rakshita. A Cloud, DevOps, AI, and Python enthusiast passionate about learning and simplifying technology for others. I love exploring how modern tools and automation can make systems smarter and more efficient. Here, I write about: ☁️ Cloud & DevOps practices 🤖 AI in the world of automation 🐍 Python for real-world problem-solving 💡 Growth, consistency, and the learner’s mindset My goal is to bridge the gap between learning and doing, and help others grow confidently in the evolving tech landscape.
Task 1: Comments
In bash scripts, comments are used to add explanatory notes or disable certain lines of code. Your task is to create a bash script with comments explaining what the script does.
Make a file named task1.sh and insert the script:
#!/bin/bash
# This script prints about what comment does
echo "The comment (#) are added with the purpose of making the source code easier for humans to understand, and are generally ignored by compilers and interpreters"
Make this file executable:
chmod 700 task1.sh
Execute the script:
./task1.sh
Task 2: Echo
The echo command is used to display messages on the terminal. Your task is to create a bash script that uses echo to print a message of your choice.
#!/bin/bash
echo "Hello, this is my Day 8 of 90DaysOfDevOPs challenge"
Run the script.
Task 3: Variables
Variables in bash are used to store data and can be referenced by their name. Your task is to create a bash script that declares variables and assigns values to them.
#!/bin/bash
name="Rakshita"
challenge="90DaysOfDevOps challenge"
echo "Hello, my name is $name and this is my day 8 of $challenge"
Run the script.
Task 4: Using Variables
Now that you have declared variables, let's use them to perform a simple task. Create a bash script that takes two variables (numbers) as input and prints their sum using those variables.
#!/bin/bash
num1=6
num2=9
sum=$((num1 + num2))
echo "The sum of $num1 and $num2 is $sum"
Run the script.
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
echo "Current user: $USER"
echo "Home directory: $HOME"
echo "Current working directory: $PWD"
Task 6: Wildcards
Wildcards are special characters used to perform pattern matching when working with files. Your task is to create a bash script that utilizes wildcards to list all the files with a specific extension in a directory.
Make few .txt files in current directory:
touch file1.txt file2.txt
Create another new file:
vim task6.sh
Enter the script:
#!/bin/bash
echo "Listing all .txt files in current directory"
ls *.txt
Make this file executable:
chmod 700 task6.sh
Run the script:
./task6.sh
Conclusion
In this series of tasks, we explored some fundamentals of bash scripting including comments, echo, commands,variables, build-in-variables and wildcards. This foundation euips us with the skills to write more complex and functional bash scripts, facilitating efficient and automated tasks in a Unix-like environment.
Happy learning!🚀




