BashBlaze-7-Days-of-Bash-Scripting-Challenge
Day 1: "Mastering the Command Line: Essential Linux Commands for Everyone"
Task 1: Comments:
A comment is a piece of text in a program or script that is ignored by the compiler or interpreter. It is used by developers to leave notes, explanations, or other information.
The shebang (#!) is used at the beginning of a script to specify the interpreter that should be used to execute the script.
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.
Output:
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.
Output :
Task 4: Using Variables
Variables can hold different types of data. Common data types include:
Types of Variables:
Integer: Used to store whole numbers (without decimals).
Example: age = 30
Float/Double: Used to store decimal numbers (with floating points).
Example: price = 19.99
String: Used to store sequences of characters (text).
Example: name = "Alice"
Boolean: Used to store True or False values.
Example: is_active = True
Array/List: Used to store a collection of multiple values (can be of the same or different types).
Example: fruits = ["apple", "banana", "cherry"]
Dictionary/Associative Array: Used to store key-value pairs.
Example: person = {"name": "Alice", "age": 30}
Output:
Task 5: Using Built-in Variables
Output
:
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.
Wildcards are special characters used in command-line interfaces and programming to represent one or more characters in strings or filenames. They provide a way to match patterns rather than specific strings, making it easier to handle groups of files or data without specifying each one individually.
Common Wildcards in Unix/Linux Shells:
Asterisk (*): Represents zero or more characters.
Example: *.txt matches all files with a .txt extension (e.g., file1.txt, document.txt, notes.txt).
Example: file* matches any file that starts with "file" (e.g., file1, file2.txt, file_example).
Question Mark (?): Represents a single character.
Example: file?.txt matches files like file1.txt, fileA.txt, but not file10.txt or file.txt (since the last one has no character where the question mark is).
Brackets ([]): Used to specify a range or set of characters.
Example: file[1-3].txt matches file1.txt, file2.txt, and file3.txt.
Example: file[a-c].txt matches filea.txt, fileb.txt, and filec.txt.
Exclamation Mark (!): Inside brackets, it can be used to specify a negation.
Example: file[!0-9].txt matches files that start with "file" followed by a character that is not a digit
Output:
"That’s it for today’s discussion! Embrace the challenges, keep learning, and I’ll see you in the next blog! 💪🌟"
In the world of Linux, there's always something new to discover. Whether you're mastering command-line magic 🧙♂️, optimizing deep learning workflows 💻, or automating tasks with scripts 🛠️, every step brings you closer to expertise. Remember, the key to success in tech is continuous learning 📚 and hands-on practice 💡. Stay curious, stay persistent, and most importantly, enjoy the journey! 🚀✨