1. Grep

Phase 1 — Basic Regex Search in a Single File

Implement core regex search functionality over a single file. Handle standard input/output and basic error cases (missing file, invalid regex).

  • Read the file line by line
  • Compile and apply regular expression
  • Print matching lines with line numbers
  • Handle file not found and invalid regex exceptions

Functional result: running grep.py "regex" file.txt displays all lines from file.txt that match the expression.


Phase 2 — Recursive Folder Search & Ignore Case

Extend functionality to search within all files in a folder recursively and to optionally ignore case sensitivity.

  • Implement recursive directory traversal
  • Process all text files found
  • Add -ignoreCase option (compile regex with re.IGNORECASE)
  • Display file name before each matching result

Functional result: running grep.py "test" C:\MyFolder -ignoreCase lists all files and lines (case-insensitive) matching the pattern.


Phase 3 — NOT and COUNT Options

Introduce advanced filtering and counting capabilities. Allow users to exclude matches or count their occurrences.

  • Implement -not option (show lines/files not matching the regex)
  • Implement -count option (show match count per file)
  • Combine with previous options (case-insensitive, recursive)

Functional result: running grep.py "pattern" folder -ignoreCase -count -not correctly counts and reports non-matching files or lines.


Phase 4 — Argument Parsing, Robustness & Reporting

Finalize the utility by improving usability, modularity, and reporting. Add CLI argument parsing, formatted output, and proper documentation.

  • Use argparse for command-line options
  • Support multiple files/folders as input
  • Add colored or formatted console output
  • Log errors and performance metrics
  • Write README and usage examples

Functional result: running various command combinations yields consistent, user-friendly results with clear error handling and documentation.