MyGrep is a command-line tool written in Rust that mimics the functionality of the Unix grep
command. It searches for a pattern in a file and displays the lines that contain it.
- Search for a string pattern in a file or from stdin
- Use regex patterns for advanced searches
- Case insensitive search
- Customize the color and formatting of the pattern found in the output
- Display line numbers of the pattern found
- Debug mode to print all the args for debugging
mygrep pattern file.txt
mygrep regex_pattern file.txt -R
mygrep pattern file.txt -I -c magenta
cat file.txt | mygrep pattern
cat file.txt | mygrep regex_pattern -R
mygrep --help
Usage: mygrep.exe [OPTIONS] <PATTERN> [PATH]
Arguments:
<PATTERN> The pattern to look for
[PATH] The path to the file to read
Options:
-c, --color <COLOR> Color to use [default: red] [possible values: red, green, blue, yellow, magenta, cyan, white, black, bright-red, bright-green, bright-blue, bright-yellow, bright-magenta, bright-cyan, bright-white]
-b, --bold Bold
-u, --underline Underline
-i, --italic Italic
-s, --strike StrikeThrough
-l, --line-numbers Show LineNumbers
-R, --regex Pattern is a Regex
-a, --after <AFTER> Show lines after the match
-b, --before <BEFORE> Show lines before the match
-S, --section Show lines before and after the match
-t, --tabs_c Value of spaces to evaluate a tab
-I, --insensitive Case Insensitive
-d, --debug Debug
-h, --help Print help
-V, --version Print version
To use mygrep
from any location in the command prompt, you need to add it to your Windows environment variables. Here's how you can do it:
-
Locate the directory where
mygrep
is installed. For example, it might beC:\Users\YourUsername\mygrep
. -
Right-click on 'This PC' (or 'My Computer') and choose 'Properties'.
-
Click on 'Advanced system settings'.
-
In the System Properties window that appears, click on the 'Environment Variables...' button.
-
In the Environment Variables window, under 'System variables', find the 'Path' variable, select it, and click 'Edit...'.
-
In the Edit Environment Variable window, click 'New' and then add the path to the
mygrep
directory. -
Click 'OK' in all windows to apply the changes.
Now, you should be able to use mygrep
from any location in the command prompt. Just type mygrep
followed by your commands.
git clone
cd mygrep
cargo build --release
Move it to the path
cp target/release/mygrep /usr/local/bin
0: Success
1: Generic Error
2: Invalid Regex Pattern
Author
Riccardo Bella raikoug@gmail.com
Latest Version 1.1.0