Rust implementation for grep tool from "The Rust Programming Language" book
This is just an implementation for educational purposes. This implementation can only search a string (in case sensitive or insensitive) within a single file. It shows all the line that contain the given string.
For a full rust implementation see the ripgrep (rg) tool.
You can build and run this CLI tool with the following syntax:
cargo run --release -- STRING FILEWhere STRING is the text to find and FILE is the path to the file
Alternatively, you can build the CLI tool and execute the binary directly, executing the following commands:
cargo build --release
cd target/release
./minigrep STRING FILEFor performing a case insensitive search, you need to create the IGNORE_CASE
env variable, for example:
# To create the temp env var and then execute the tool
IGNORE_CASE=1 cargo run --release -- STRING FILE
# To create the "permanent" env var and then execute the tool
export IGNORE_CASE=1 && cargo run --release -- STRING FILEYou can run the test using the following command:
cargo test --release