Expand description
A minimal implementation of grep in rust.
§Overview
grepr is a simple command line search tool. A search string and file path are input as arguments, along with several optionals to fine tune the search. The program iterates through each line in the specified file and will return any lines matching the search criteria.
§Examples
A simple search example.
$ grepr sunbeam tests/pale_blue_dot.txt
test/pale_blue_dot.txt
11: on a mote of dust suspended in a sunbeam.
Search for an exact word. In this case any non-alphanumeric characters are ignored.
$ grepr in tests/pale_blue_dot.txt -w
test/pale_blue_dot.txt
6: civilization, every king and peasant, every young couple in love,
9: "superstar," every "supreme leader," every saint and sinner in
11: on a mote of dust suspended in a sunbeam.
Inverting the search results. All lines without a match are returned.
$ grepr a tests/pale_blue_dot.txt -v
test/pale_blue_dot.txt
1: On it everyone you love, everyone you know, everyone you ever
10: the history of our species lived there--
12:
Structs§
- Command
Args - A parser for command line input.
- Search
- Stores the results of the search and a reference to the contents.