Skip to content

Grepz is a versatile command-line tool for searching and highlighting specific terms or regex in a text file. Its customizable color options and ability to display lines before and after a match provide context, and it also offers a special reporting mode that highlights matches with a box.

License

Notifications You must be signed in to change notification settings

shockz-offsec/Grepz

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Grepz

Grepz is a versatile command-line tool that offers various options for searching and highlighting specific terms or regex in a text file. With its customizable color options, users can highlight matches with a chosen background or foreground color. Additionally, Grepz allows users to view the context of the match by displaying the lines before and after it.

For reporting purposes, Grepz offers a special mode that highlights matches with a box, making it easy to spot them in a text file. Whether you need to quickly search for a term or carefully review a document, Grepz is a powerful and flexible tool that can help you achieve your goals.

Installation

To install Grepz, run the following command:

go get github.com/shockz-offsec/grepz

or via building via repository

git clone https://github.com/shockz-offsec/Grepz.git
cd Grepz
go build -o grepz grepz.go

Download the compiled binary for Windows, Linux or MacOS

Download the latest version

Please, if you are going to use powershell on Windows 10 you must:

Activate Support VT (Virtual Terminal) / ANSI escape sequences globally by default, persistently.

Set-ItemProperty HKCU:\Console VirtualTerminalLevel -Type DWORD 1

Usage

grepz [-i] [-box|-b] [-up num] [-down num] <search_term> [<input_file>]
  • -i: Performs a case-insensitive search.
  • -box or -b: Highlights the matches inside a box.
  • -up num: Displays a specified number of lines before the match.
  • -down num: Displays a specified number of lines after the match.
  • <search_term>: The term you want to search for. Regular expressions are accepted.
  • <input_file>: The file in which you want to search. If this parameter is not provided, it is read from the standard input by pipping.

Context funtionality

The context functionality allows grouping in the same context several occurrences that are within the range specified by the -up or -down parameters. This will make it easier to understand and analyze them together. In case the occurrences are not in range, they will be shown in different contexts, but always accompanied by their respective context lines for a better understanding.

Colors

The background and foreground colors can also be changed by using the -bg and -fg flags followed by one of the following colors: red, green, yellow, blue, magenta, cyan, white, black or pink.

  • The default background color is magenta and the foreground color is white.

  • Box color is red by default.

Examples

Search for the term world in the file myfile.json, using a case-insensitive search and highlight the match in cyan:

grepz -i -bg cyan "hello" myfile.json

Search for the term Hello in the file myfile.json, display 3 lines before and after the match:

grepz -up 3 -down 3 "Hello" myfile.json

Now the same example but highlighting the match with a box:

grepz -b -up 3 -down 3 "Hello" myfile.json

Search for the term hello in the myfile.json file, using a case-insensitive search, and highlight the match with a yellow box and magenta text:

grepz -i -b -bg yellow -fg magenta "hello" myfile.json

ToDo

  • Allow recursive searches in files

Credits

Shockz OffSec & Siriil

License

This tool is licensed under the GPL-3.0 License.

About

Grepz is a versatile command-line tool for searching and highlighting specific terms or regex in a text file. Its customizable color options and ability to display lines before and after a match provide context, and it also offers a special reporting mode that highlights matches with a box.

Topics

Resources

License

Stars

Watchers

Forks

Languages