Crates.io | minigrep_elijahkx |
lib.rs | minigrep_elijahkx |
version | 0.1.2 |
source | src |
created_at | 2023-11-30 07:42:23.37593 |
updated_at | 2023-11-30 09:34:40.738049 |
description | MiniGrep is a Rust-based command-line tool, with a (current) size of 588KB that lets users search files for a given query string and shows matching lines with their line numbers. |
homepage | https://www.elijahkoulaxis.com |
repository | https://github.com/kx0101/minigrep |
max_upload_size | |
id | 1053966 |
size | 397,572 |
MiniGrep is a simple command-line utility written in Rust for searching text within files. It provides the capability to search for a specified query string in a given file, displaying lines containing the query along with their line numbers.
minigrep [query] [file path(s)] [-i]
# Perform a case-sensitive search for the word "hello" in the file "sample.txt"
minigrep hello sample.txt
# Perform a case-sensitive search for the word "hello" in the files "sample.txt" and "sample2.txt"
minigrep hello sample.txt sample2.txt
# Perform a case-sensitive search for the word "hello" in all the files in your current directory.
minigrep hello .
# Perform a case-insensitive search for the word "world" in the file "sample.txt"
minigrep world sample.txt -i
# Redirects the output to a new file. Error messages are not captured in the output file.
minigrep world sample.txt > output.txt
The program uses the following components:
query
and n is the length of the contents
k
is the space used for storing the matches.The program utilizes multiple threads for concurrent file processing to enhance search speed when searching in multiple files. Each file search operation runs in its own thread.
cargo test
The program will display lines containing the query string along with their line numbers within the specified file. If no matching lines are found, it will indicate that the query was not found in the file.