Before running MyGrep, make sure you have the following tools installed on your system:
-
Rust:
- MyGrep is a Rust project, and you need the Rust programming language installed. You can install Rust by following the instructions on the official Rust website.
-
Cargo:
- Cargo is the official package manager and build tool for Rust. It is usually included with the Rust installation.
To use MyGrep, follow these steps:
-
Clone the repository:
git clone https://github.com/yourusername/mygrep.git
-
Navigate to the project directory:
cd mygrep
-
Build the project:
cargo build --release
-
Run MyGrep with the desired
query
andfile path
:./target/release/mygrep query file_path
You can also set the IGNORE_CASE environment variable to perform a case-insensitive search:
IGNORE_CASE=1 ./target/release/mygrep query file_path
Suppose you have a file named example.txt
with the following content:
Rust:
safe, fast, productive.
Pick three.
Duct tape.
To search for the query "duct" in a case-sensitive manner, run the following command:
./target/release/mygrep duct example.txt
To perform a case-insensitive search, set the IGNORE_CASE environment variable:
IGNORE_CASE=1 ./target/release/mygrep duct example.txt
This will output:
Duct tape.