# πŸ“˜ Week 1 Β· Day 5 β€” Bash Exercises This README documents **all exercises for Week 1 Day 5**, focused on **Bash scripting for Linux system administration and security workflows**. The exercises mirror the logic implemented previously in **C, Python, SQL, and PowerShell**, reinforcing algorithmic thinking while introducing **Unix shell syntax, conditionals, loops, and defensive scripting**. --- ## 🎯 Learning Objectives By completing today’s exercises, you will: * Use Bash variables and user input (`read`) * Apply conditional logic with `if / elif / else` * Loop over strings and arrays using `for` * Perform character validation using regex * Implement secure input validation logic * Analyze algorithm runtime and scalability * Gain confidence writing Linux automation scripts --- ## πŸ›  Exercises Overview ### πŸ§ͺ Exercise 1 β€” Even / Odd Number Checker **Task:** * Prompt the user for a number * Determine whether the number is `Even` or `Odd` **Concepts practiced:** * Numeric input handling * Arithmetic expressions: `(( ))` * Conditional branching --- ### πŸ§ͺ Exercise 2 β€” Count Letters in a String **Task:** * Prompt the user for a string * Count **letters only** (`A–Z`, `a–z`) * Ignore spaces, digits, and special characters **Concepts practiced:** * Looping over string characters * Regex matching using `[[ =~ ]]` * Counter variables --- ### πŸ§ͺ Exercise 3 β€” Username Validator (Single User) **Task:** Validate a username using these rules: * Length ≀ 20 characters * Starts with a letter * Contains letters only * No digits * No spaces **Output:** * `Accepted` or `Refused` **Concepts practiced:** * Defensive input validation * Early exit with `break` * String length checking * First-character validation --- ### πŸ§ͺ Exercise 4 β€” Validate Multiple Usernames **Input:** ```bash users=("admin" "root1" "John_Doe" "Alice" "Bob42") ``` **Task:** * Loop through each username * Apply the same validation rules as Exercise 3 * Print whether each username is valid or invalid **Concepts practiced:** * Array iteration * Nested loops * Reusable validation logic --- ### πŸ§ͺ Exercise 5 β€” Algorithm Analysis (Written) **Task:** Explain what happens to execution time if the number of usernames doubles. Use: * `n` = number of usernames * `m` = average username length **Expected result:** ``` T(n, m) = n Γ— m T(2n, m) = 2 Γ— n Γ— m Big-O: O(nΒ·m) ``` --- ## πŸ” Security & Sysadmin Perspective These exercises reflect real-world Bash usage in: * Linux user management * Input validation scripts * SSH and access control automation * Log parsing and monitoring * Security audits and recon scripts Strong validation and predictable runtime are critical for **secure and reliable system scripts**. --- ## βœ… Completion Criteria Day 5 is complete when: * Exercises 1–4 run correctly in Bash * Exercise 5 clearly explains runtime scaling * Scripts follow safe Bash practices (`[[ ]]`, quoting, defensive checks) --- ## πŸ”œ Next Step After Day 5, Week 1 concludes. Upcoming: * **Week 2:** Data Structures (arrays, maps, sets) * Stronger algorithm focus * More security-oriented scripting examples --- πŸ“Œ *This README serves as a reference and checklist for Week 1 Day 5 Bash exercises.*