Skip to content

iamprinceefe/30DaysOfBashScript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

- Day 1: Bash Script - Greeting Interaction

For the first day of the #30DaysOfBashScript challenge, I created a simple Bash script that simulates a brief greeting interaction between two individuals, Prince and Mariam. The script demonstrates the basics of echo commands and user input in Bash scripting. A great starting point for beginners looking to understand Bash fundamentals!

- Day 2: Bash Script Project - Directory Structure, Navigation, and File Manipulation

In Day 2 of the #30DaysOfBashScript challenge, I focused on creating a directory structure, practicing navigation commands, manipulating files, and performing searches within a project directory. The challenge also involved automating the creation of the directory structure through a Bash script.

Exercises Completed:

  1. Directory Structure Creation:

    • Created a directory called project in my home directory.
    • Inside project, created three subdirectories: docs, src, and tests.
    • Created an empty README.md file in each subdirectory.
  2. Navigation Practice:

    • Practiced navigation commands to move around the directory structure:
      • Used a single command to navigate from the home directory to the src directory.
      • Listed the contents of the src directory.
      • Moved back to the project directory.
      • Listed all subdirectories of the project directory in long format using ls -l.
  3. File Manipulation:

    • Created a file called todo.txt in the project directory.
    • Used the echo command with output redirection to add the line "Complete Bash scripting course" to the todo.txt file.
    • Copied todo.txt to the docs directory and renamed it to tasks.txt.
  4. Search and Display:

    • Used the find command to locate all README.md files within the project directory and its subdirectories.
    • Used grep to search for the word "Complete" in all text files within the project directory.
  5. Cleanup:

    • Removed the tests directory and all its contents.
    • Moved the tasks.txt file from docs to src for organization.

Bonus Challenge:

  • Wrote a Bash script to automate the creation of the directory structure from Exercise 1, which includes creating the project directory and its subdirectories (docs, src, and tests) with README.md files.

NOTE: Find the script in the code section

Walkthrough:

Disk Sanitization Steps



Disk Sanitization Steps



Disk Sanitization Steps



Disk Sanitization Steps



Disk Sanitization Steps



Disk Sanitization Steps



This exercise helped me solidify my understanding of basic Bash commands, file manipulation, and navigation while also introducing me to directory management and search commands within the terminal. The automation part, with the Bash script, provided hands-on experience in scripting for task automation.

- Day 3: Interactive Bash Script

This script is part of my 30-day Bash scripting challenge. In this project, I created an interactive script that performs the following tasks:

•	Asks the user for their name and age, then confirms the details entered.
•	Reads a list of the user’s favorite books and adds one to the list.
•	Asks for the user’s mentor and favorite impactful messages.
•	Displays the current user, directory, and the system’s date/time using command substitution.
•	Accepts two numeric command-line arguments to perform basic arithmetic operations (addition, subtraction, multiplication).

Key Concepts:

•	User Input: Using read to get user input.
•	Arrays: Declaring and working with arrays to store and display data.
•	Command Substitution: Using $(...) to execute commands and store their outputs (e.g., getting current user and directory).
•	Arithmetic Operations: Performing basic operations on command-line inputs.

- Day 4: Control Flow

In this project, I completed exercises that helped improve my Bash scripting skills. The scripts I created cover basic operations like input handling, file management, conditional checks, and user permission validation.

Exercises Completed:

  1. Check if a number is positive, negative, or zero:

    • A script that takes a number as input and determines whether it's positive, negative, or zero.
  2. Check if a file exists:

    • A script that checks if a specified file exists. If the file is found, it prints the contents; otherwise, it creates the file with default text.
  3. Compare two numbers:

    • A script that compares two numbers provided as command-line arguments and prints whether the first number is greater than, less than, or equal to the second number.
  4. Check write permissions on a file:

    • A script that checks if the user running the script has write permissions for a specified file, printing an appropriate message based on the result.
  5. Age and name validation:

    • A script that asks the user for their age and name. If the user is 18 or older and their name is "Admin," the script grants access; otherwise, it denies access.

This project enhanced my understanding of Bash scripting concepts such as conditionals, user input, file operations, and permission checks. It’s a great foundation for building more complex scripts in the future.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages