tre-agrep(1)
π tre-agrep(1) β the manual page, but make it bestie-friendly π
okay so this is the page for tre-agrep from the General Commands Manual, and honestly? it's giving "fuzzy matching but make it cute". let's get into it π«Ά
β¨ NAME β¨
tre-agrep β prints lines that approximately match a pattern. like, it's not gonna be weird about a typo, she's forgiving π
πΈ SYNOPSIS πΈ
tre-agrep [OPTION]... PATTERN [FILE]...
π¦ DESCRIPTION π¦
So the whole vibe: it searches for approximate matches of PATTERN in each FILE, or in standard input if you don't hand it any files. no cap.
Example time, because examples ate:
tre-agrep -2 optimize foo.txt
that outputs all the lines in the file foo.txt that match "optimize" within two errors. so like, lines containing "optimise", "optmise", and "opitmize" all match. bestie it literally does not care about your typos, it loves you anyway πβ¨
π OPTIONS π
Regexp selection and interpretation:
-e PATTERN,--regexp=PATTERNβ use PATTERN as a regular expression. highkey useful when you need to protect patterns that start with-, because otherwise the shell is gonna think it's a flag and start drama π-i,--ignore-caseβ ignore case distinctions in PATTERN and in the input files (as defined by the current locale). uppercase? lowercase? she does not perceive the difference π-k,--literalβ treat PATTERN as a literal string, meaning a fixed string with no special characters. what you see is what you get, periodt.-w,--word-regexpβ force PATTERN to match only whole words. and a "whole word" is a substring that either starts at the beginning of the record or is preceded by a non-word constituent character. similarly, the substring must either end at the end of the record or be followed by a non-word constituent character. word-constituent characters are alphanumerics (as defined by the current locale) plus the underscore character. β οΈ and listen: those non-word constituent characters must surround the match β they cannot be counted as errors. noted, bestie.
Approximate matching settings:
-D NUM,--delete-cost=NUMβ set the cost of missing characters to NUM. like how expensive is it to forget a letter π-I NUM,--insert-cost=NUMβ set the cost of extra characters to NUM. how expensive is it to add a letter nobody asked for.-S NUM,--substitute-cost=NUMβ set the cost of incorrect characters to NUM. and here's the tea: a deletion (a missing character) and an insertion (an extra character) together constitute a substituted character, but the cost will be the deletion and insertion costs added together. so if you set the cost of a substitution to be larger than the sum of the costs of deletion and insertion, direct substitutions will never be done. that's just math, bestie π§-E NUM,--max-errors=NUMβ select records that have at most NUM errors.-#β select records that have at most#errors, where#is a digit between0and9. yes it's just a number glued onto the flag, she's efficient like that π
Miscellaneous:
-d PATTERN,--delimiter=PATTERNβ set the record delimiter regular expression to PATTERN. the text between two delimiters, before the first delimiter, and after the last delimiter is considered to be a record. the default record delimiter is the regexp"\n", so by default a record is just a line. PATTERN can be any regular expression that does not match the empty string. for example, using-d "^From "defines mail messages as records in a Mailbox format file. iconic use case tbh π¬-v,--invert-matchβ select non-matching records instead of matching records. the contrarian queen π-V,--versionβ print version information and exit. short and sweet.-y,--nothingβ does nothing. literally nothing. this option exists only for compatibility with the non-freeagrepprogram. she's just standing there, existing, for the plot π--helpβ display a brief help message and exit.
Output control:
-B,--best-matchβ only output the best matching records, that is, the records with the lowest cost. β οΈ this is currently implemented by making two passes over the input files, and it cannot be used when reading from standard input. so no piping, bestie, sorry π--color,--colourβ highlight the matching strings in the output with a color marker. the color string is taken from theGREP_COLORenvironment variable, and the default color is red. π-c,--countβ only print a count of matching records for each input file, suppressing the normal output. numbers only, no chatter.-h,--no-filenameβ suppress the prefixing filename on output when multiple files are searched. keep it anonymous πΆοΈ-H,--with-filenameβ prefix each output record with the name of the input file where the record was read from. receipts included π-l,--files-with-matchesβ only print the name of each input file which contains at least one match, suppressing normal output. and the scanning for each file stops on the first match β she doesn't linger.-m NUM,--max-count=NUMβ stop processing each input file after NUM matching lines (or non-matching lines if-vwas specified). a negative value is interpreted as infinity, which is the default. infinity!! main character energy βΎοΈ-n,--record-numberβ prefix each output record with its sequence number in the input file. the number of the first record is1. (not zero, bestie, we're not doing that here)-q,--quiet,--silentβ do not write anything to standard output. exit immediately with zero exit status if a match is found. the strong silent type π€«-s,--show-costβ print match cost with output.--show-positionβ prefix each output record with the start and end offset of the first match within the record. the offset of the first character of the record is0, and the end position is given as the offset of the first character after the match. precise. β¨-M,--delimiter-afterβ by default, the record delimiter is the newline character and is output after the matching record. if-dis used, the record delimiter will be output before the matching record. this option causes the delimiter to be output after the matching record. she said "put it back" π
With no FILE, or when FILE is -, it reads standard input. and if less than two *FILE*s are given, -h is assumed β otherwise -H is the default. iykyk π«Ά
π DIAGNOSTICS π
Exit status is 0 if a match is found, 1 for no match, and 2 if there were errors.
and important: if -E or -# is not specified, only exact matches are selected. so if you were expecting fuzzy magic without asking for it β no ma'am, you gotta opt in.
PATTERN is a POSIX extended regular expression (ERE) with the TRE extensions. fancy. π
π REPORTING BUGS π
Report bugs to the TRE mailing list <tre-general@lists.laurikari.net>. she wants to hear from you, fr fr.
π COPYRIGHT π
Copyright Β© 2002-2004 Ville Laurikari.
This is free software, and comes with ABSOLUTELY NO WARRANTY. you are welcome to redistribute this software under certain conditions; see the source for the full license text.
and that's the whole page bestie π this was TRE agrep 0.9.0, dated November 21, 2004 β old but iconic, slay, bye π¦β¨
π¦ where this page comes from
- debian trixie: tre-agrep 0.9.0-1
- ubuntu questing: tre-agrep 0.9.0-1
- ubuntu resolute: tre-agrep 0.9.0-1build1
- ubuntu stonking: tre-agrep 0.9.0-2
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms