MiniGrep is a simple command-line tool written in Rust that allows you to search for a specific query string in a given text file. It provides both case-sensitive and case-insensitive search options.
To use MiniGrep, follow these steps:
git clone https://github.com/andersonmarin/minigrep
cargo build
cargo run -- <query> <file_path>
Replace <query>
with the text you want to search for and <file_path>
with the path to the text file you want to
search in.
You can run the unit tests for MiniGrep using the following command:
cargo test
This will execute the test cases defined in the tests
module of the code, ensuring the correctness of the search
functions and other components.
By default, the search is case-sensitive. However, you can enable case-insensitive search by setting the IGNORE_CASE
environment variable:
export IGNORE_CASE=1
To perform a case-sensitive search for the query "duct" in the following content:
Rust:
safe, fast, productive.
Pick three.
Run the following command:
cargo run -- duct path/to/file.txt
You should see the output:
safe, fast, productive.
To perform a case-insensitive search for the query "rUsT" in the following content:
Rust:
safe, fast, productive.
Pick three.
Trust me.
Run the following command:
export IGNORE_CASE=1
cargo run -- rUsT path/to/file.txt
You should see the output:
Rust:
Trust me.
This repository and its contents are intended for educational and study purposes only. The code and documentation provided are not intended for production use. Use at your own risk.