Mini Grep is a command-line tool written in C++ that allows you to search for specific text patterns within files. It is designed to provide basic text searching functionality similar to the Unix grep
command.
- Search for text patterns within files.
- Display matching lines.
- Perform case-sensitive or case-insensitive searches.
- Search for patterns using regular expressions (regex).
- Output results to the console or a file.
To use Mini Grep, follow these basic usage instructions:
-
Compile the program: You can compile the source code using a C++ compiler like g++ or cmake.
mkdir build && cd build
cmake ..
make
-
Run the program with the desired options:
./minigrep [options] pattern file
-
[options]
:-i
: Perform a case-insensitive search.-r
: Use regular expressions for pattern matching.-o <output_file>
: Specify an output file for results.
-
pattern
: The text pattern you want to search for. -
file
: The name of the file or files you want to search within.
-
-
Search for the word "bog" in a file:
./mini_grep bog ../poem.txt
-
Perform a case-insensitive search for "pattern" in multiple files:
./mini_grep -i pattern file1.txt file2.txt
-
Use regular expressions to search for email addresses and save the results to a file:
./mini_grep -r -o results.txt "^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}$" emails.txt
This project is licensed under the MIT License. See the LICENSE file for details.
Feel free to contribute to the project by submitting pull requests or opening issues on the GitHub repository.
This is a basic implementation of a grep-like tool in C++. It may not have all the features or performance of the standard Unix grep
command.