tre-agrep(1)

πŸ“¦
version 0.9.0 Β· 2 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– 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 between 0 and 9. 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-free agrep program. 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 the GREP_COLOR environment 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 -v was 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 is 1. (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 is 0, 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 -d is 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 Β© 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