90 Snippets: Unraveling My Tech Superpowers! ๐Ÿงช

90 Snippets: Unraveling My Tech Superpowers! ๐Ÿงช

90 Projects towards mastery - Day 00 ๐Ÿš€

ยท

4 min read

Hey there, folks! I'm Astro, and today's the kickoff of my epic journey, "90 Snippets," where I'm gonna level up my tech skills like a pro. It's the 18th of July, 2023, and I'm stoked to share my first-day adventures with you.

Day 00: Shell Scripting - Let's Get This Party Started! ๐Ÿš€

So, I started off with shell scripting, and I gotta admit, it felt kinda cool! All those lines of code dancing in the terminal - mesmerizing! ๐Ÿ’ป

Challenge

Write a shell script that prompts a user for their name and then prints out a greeting followed by their name.

Bonus: To make this challenge more fun, discover conditionals and the use of variables in shell scripting and craft something fun! ๐Ÿ”ฅ

Solution

Check the source code on GitHub: here

Step 1: Setting Up the Script

#!/bin/bash

# Global variable
password="whocaresabtencryption"

We begin by setting up the script with the shebang (#!/bin/bash), which tells the system to run the script using the Bash shell. Then, we create a global variable called password and set its initial value to "whocaresabtencryption."

Step 2: User Input and Greeting

# Prompt
echo -n "username: "
read name

# Greeting
echo "Hello and welcome $name!"

Next, we prompt the user to enter their username with echo -n, which displays the message without a newline. The read command reads the user's input and stores it in the variable name. After that, we greet the user using their entered name.

Step 3: Conditional Logic

# Playing around
if [ "$name" == "astro" ]; then
    echo -n "Password please ?_?: "
    read password
else
    echo "Have a good day!"
fi

In this snippet, we use conditional logic to check if the username entered by the user is "astro." If it is, we prompt the user to enter a password and read it into the password variable. If the username is anything other than "astro," we simply wish the user a good day.

Step 4: Password Verification and Next Level

if [ "$password" == "ortsa" ]; then
    echo "I'll take you to the next level"
    cd ../ex01
    echo "Enjoy hacking!"
elif [ "$password" != "whocaresabtencryption" ]; then
    echo "Incorrect password XD"
fi

Here, we check if the password entered by the user matches "ortsa" (which is "astro" spelled backward). If it does, we give them a cool message about taking them to the next level and change the current directory to "../ex01." It's like a secret level unlocked in a game! ๐ŸŽฎ If the password is not "whocaresabtencryption," we tease them with a fun "Incorrect password XD" message.

Learning + Growth = Future Super Me ๐ŸŒŸ

You know what's cool? Learning new stuff feels like unlocking doors to a world of infinite possibilities. It's like finding a missing piece of the puzzle that makes the whole picture come alive! ๐Ÿงฉ

Sure, there'll be hurdles along the way. Bugs, errors, and all that jazz. But I'm no quitter! I'll take 'em on like a champ, learn from 'em, and grow stronger. ๐Ÿ’ช

Next: Shell Scripting Day 01 - Mastering the Basics ๐Ÿ”

Next on my list is Day 01 Shell Scripting!

This challenge requires me to write a script to manipulate files and directories, it's all about automating a task that we do so often.

Challenge

Create a script that takes a directory as input and organizes its files into subdirectories based on their file extensions (e.g., move all ".txt" files to a "TextFiles" folder).

Bonus: Let the script take a file extension as an argument and use it to only organize files of that specific extension

Well, I guess it's time for reading docs and watching some YouTube videos.

By Thor, by Odin, I'm determined to finish the whole shell scripting topic and claim victory before moving on to the next! ๐Ÿ”ฅ

Keep Hustlin', Keep Crushin' It! ๐Ÿ’ฅ

I'm excited, peeps! This "90 Snippets" adventure is just beginning, and I'm pumped to take on each topic, one project at a time. It's not just about becoming a tech whiz; it's about becoming a better version of me! ๐Ÿš€

To all my fellow tech enthusiasts out there: Never shy away from challenges. Embrace 'em with open arms and a curious mind. Let's hustle, let's crush it, and let's uncover the tech superheroes within us! ๐Ÿฆธโ€โ™‚๏ธ

So stay tuned, my friends, for more updates on my wild tech escapades. Until next time, keep coding, keep dreaming, and keep pushing those boundaries!

By Thor, by Odin, let's make it super cool! ๐ŸŒŸโœŒ๏ธ

Let me know in the comments if you'd like to join me on this journey ๐Ÿš€

ย