1 unstable release

Uses new Rust 2024

0.1.0 Oct 29, 2025

#2407 in Command line utilities

MIT/Apache

6KB

Pattern Search Tool

A simple command-line utility written in Rust that searches for a pattern in a file and displays all matching lines.

Features

  • Search for a pattern string within a file
  • Display all lines containing the pattern
  • Clear error messages with context
  • Efficient line-by-line processing

Prerequisites

  • Rust 1.70 or later
  • Cargo (comes with Rust)

Installation

Clone the repository and build the project:

git clone https://github.com/siddharth-09/grep-cli-clone
cd grep-cli-clone
cargo build --release

The compiled binary will be available at target/release/pattern-search.

Usage

Run the tool with a pattern and file path:

cargo run -- <PATTERN> <FILE_PATH>

Examples

Search for "error" in a log file:

cargo run -- "error" logs/app.log

Search for a function name in source code:

cargo run -- "fn main" src/main.rs

Using the compiled binary directly:

./target/release/pattern-search "TODO" notes.txt

Dependencies

  • anyhow - Error handling with context
  • clap - Command-line argument parsing

Error Handling

The tool provides helpful error messages if the file cannot be read:

could not read file `nonexistent.txt`

License

MIT

Dependencies

~4–6.5MB
~115K SLoC