Rust Project: Minigrep
mini-grep
A simple, grep-like command-line tool written in Rust. It allows you to search for a specific string pattern within a text file.
Initial primary release! Will integrate more functions and capabilities in the future.
Features
- Search for a text pattern in a specified file.
- Case-sensitive search by default.
- Case-insensitive search can be enabled via an environment variable.
Usage
To use mini-grep
, you need to provide two arguments: a search pattern and the path to the file you want to search in.
Basic Search (Case-Sensitive)
To perform a case-sensitive search, run the program with the following command structure:
1 |
|
Example:
1 |
|
This command will search for the exact word “hello” in the poem.txt
file and print any lines that contain it.
Case-Insensitive Search
You can perform a case-insensitive search by setting the IGNORE_CASE
environment variable before running the command.
On Linux/macOS:
1 |
|
On Windows (PowerShell):
1 |
|
Example:
1 |
|
This command will search for “rUsT” (and “rust”, “Rust”, “RUST”, etc.) in poem.txt
and print all matching lines, regardless of their casing.
Todo List
- feat: add iterator for function programming
- Add recursive search for folders
- Add Regex search
- Add fuzzy search
Code
Just as a toy implementation… Still needs to be improved.
1 |
|
1 |
|