Anthony's Blog Site

grep Plus

November 02, 2024

Grep Plus Demo

Photo Credit: Anthony Cui


This project is an advanced implementation in Rust of the well-known grep utility on Unix-like operating systems, which shows search results of a given keyword with supplementary features like keyword highlighting, case-insensitive search, and match details.

For example, if a user wants to search for the word "classifier" (in the context of NLP language models like this) in all Markdown files (*.md) regardless of uppercase or lowercase (-i) with all matches highlighted (-c) and their locations displayed (-f and -n), they may run cargo run classifier ./*.md -i -c -f -n. To explore the full functionalities of this search tool, you may use cargo run --help and read the instructions it gives.

The code was designed to take advantage of some key features in Rust such as lifetimes (e.g. using 'static) and error handling (e.g. error boxing with Box and error propagation using ?), and these are exactly some reasons why Rust is considered to be a more reliable choice than C or C++. Some sample test files are already provided in the source code on GitHub, so feel free to try this utility out yourself!