{"id":18151219,"url":"https://github.com/msantos/trep","last_synced_at":"2025-04-28T17:41:15.201Z","repository":{"id":136621807,"uuid":"83328997","full_name":"msantos/trep","owner":"msantos","description":"Selectively stream stdin to stdout/stderr based on regular expressions","archived":false,"fork":false,"pushed_at":"2025-01-09T12:49:32.000Z","size":126,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-30T11:41:35.478Z","etag":null,"topics":["capsicum","grep","pledge","seccomp","setrlimit","stdio"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/msantos.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-02-27T16:03:05.000Z","updated_at":"2025-01-09T12:49:35.000Z","dependencies_parsed_at":"2024-08-25T13:26:43.439Z","dependency_job_id":"768facb8-0965-4e5e-a5e4-6c298d4d65bf","html_url":"https://github.com/msantos/trep","commit_stats":{"total_commits":85,"total_committers":1,"mean_commits":85.0,"dds":0.0,"last_synced_commit":"99e9be341b35b3169158bda08ae5185a9866da59"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msantos%2Ftrep","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msantos%2Ftrep/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msantos%2Ftrep/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msantos%2Ftrep/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/msantos","download_url":"https://codeload.github.com/msantos/trep/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251357454,"owners_count":21576709,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["capsicum","grep","pledge","seccomp","setrlimit","stdio"],"created_at":"2024-11-02T01:06:58.738Z","updated_at":"2025-04-28T17:41:15.182Z","avatar_url":"https://github.com/msantos.png","language":"C","readme":"TREP(1) BSD General Commands Manual TREP(1)\n\n**NAME**\n\n**trep** — Selectively stream stdin to stdout/stderr based on regular expressions\n\n**SYNOPSIS**\n\n**trep** \\[**−abcEFGHhIiLlnoqRsUVvwx**\\] \\[**−A** *num*\\] \\[**−B** *num*\\] \\[**−C**\\[*num*\\]\\] \\[**−e** *pattern*\\] \\[**−f** *file*\\] \\[**−-binary-files**=*value*\\] \\[**−-context**\\[=*num*\\]\\] \\[**--label=name**\\] \\[**−-line-buffered**\\] \\[**−-stream-with-match**=\\[*stdout* | *stderr* | *null*\\]\\] \\[**−-stream-without-match**=\\[*stdout* | *stderr* | *null*\\]\\] \\[*pattern*\\] \\[*file ...*\\]\n\n**DESCRIPTION**\n\n**trep** (tee-rep) combines tee(1) and grep(1) to select input using a regular expression and output to stdout or stderr based on the match. **trep** is a fork of OpenBSD grep and so supports all the usual grep(1) options.\n\nThe **trep** utility searches any given input files, selecting lines that match one or more patterns. By default, a pattern matches an input line if the regular expression (RE) in the pattern matches the input line without its trailing newline. An empty expression matches every line. Each input line that matches at least one of the patterns is written to the standard output. If no file arguments are specified, the standard input is used.\n\n**trep** is used for simple patterns and basic regular expressions (BREs); **etrep** can handle extended regular expressions (EREs). See re\\_format(7) for more information on regular expressions. **ftrep** is quicker than both **trep** and **etrep**, but can only handle fixed patterns (i.e. it does not interpret regular expressions). Patterns may consist of one or more lines, allowing any of the pattern lines to match a portion of the input.\n\nThe following options are available:\n\n**−A** *num*\n\nPrint *num* lines of trailing context after each match. See also the **−B** and **−C** options.\n\n**−a**\n\nTreat all files as ASCII text. Normally **trep** will simply print ’’Binary file ... matches’’ if files contain binary characters. Use of this option forces **trep** to output lines matching the specified pattern.\n\n**−B** *num*\n\nPrint *num* lines of leading context before each match. See also the **−A** and **−C** options.\n\n**−b**\n\nThe offset in bytes of a matched pattern is displayed in front of the respective matched line.\n\n**−C**\\[*num*\\]\n\nPrint *num* lines of leading and trailing context surrounding each match. The default is 2 and is equivalent to **−A** *2* **−B** *2*. Note: no whitespace may be given between the option and its argument.\n\n**−c**\n\nOnly a count of selected lines is written to standard output.\n\n**−E**\n\nInterpret *pattern* as an extended regular expression (i.e. force **trep** to behave as **etrep**).\n\n**−e** *pattern*\n\nSpecify a pattern used during the search of the input: an input line is selected if it matches any of the specified patterns. This option is most useful when multiple **−e** options are used to specify multiple patterns, or when a pattern begins with a dash (’-’).\n\n**−F**\n\nInterpret *pattern* as a set of fixed strings (i.e. force **trep** to behave as **ftrep**).\n\n**−f** *file*\n\nRead one or more newline separated patterns from *file*. Empty pattern lines match every input line. Newlines are not considered part of a pattern. If *file* is empty, nothing is matched.\n\n**−G**\n\nInterpret *pattern* as a basic regular expression (i.e. force **trep** to behave as traditional **trep**).\n\n**−H**\n\nAlways print filename headers (i.e. filenames) with output lines.\n\n**−h**\n\nNever print filename headers (i.e. filenames) with output lines.\n\n**−I**\n\nIgnore binary files.\n\n**−i**\n\nPerform case insensitive matching. By default, **trep** is case sensitive.\n\n**−L**\n\nOnly the names of files not containing selected lines are written to standard output. Pathnames are listed once per file searched. If the standard input is searched, the string ’’(standard input)’’ is written.\n\n**−l**\n\nOnly the names of files containing selected lines are written to standard output. **trep** will only search a file until a match has been found, making searches potentially less expensive. Pathnames are listed once per file searched. If the standard input is searched, the string ’’(standard input)’’ is written.\n\n**−n**\n\nEach output line is preceded by its relative line number in the file, starting at line 1. The line number counter is reset for each file processed. This option is ignored if **−c**, **−L**, **−l**, or **−q** is specified.\n\n**−o**\n\nPrint each match, but only the match, not the entire line.\n\n**−q**\n\nQuiet mode: suppress normal output. **trep** will only search a file until a match has been found, making searches potentially less expensive.\n\n**−R**\n\nRecursively search subdirectories listed.\n\n**−s**\n\nSilent mode. Nonexistent and unreadable files are ignored (i.e. their error messages are suppressed).\n\n**−U**\n\nSearch binary files, but do not attempt to print them.\n\n**−V**\n\nDisplay version information. All other options are ignored.\n\n**−v**\n\nSelected lines are those *not* matching any of the specified patterns.\n\n**−w**\n\nThe expression is searched for as a word (as if surrounded by ’\\[\\[:\u0026lt;:\\]\\]’ and ’\\[\\[:\u0026gt;:\\]\\]’; see re\\_format(7)).\n\n**−x**\n\nOnly input lines selected against an entire fixed string or regular expression are considered to be matching lines.\n\n**−−binary-files**=*value*\n\nControls searching and printing of binary files. Options are *binary*, the default: search binary files but do not print them; *without-match*: do not search binary files; and *text*: treat all files as text.\n\n**−−context**\\[=*num*\\]\n\nPrint *num* lines of leading and trailing context. The default is 2.\n\n**--label**\\[=*name*\\]\n\nPrint name instead of the filename before lines.\n\n**−−line-buffered**\n\nForce output to be line buffered. By default, output is line buffered when standard output is a terminal and block buffered otherwise.\n\n**−−stream-with-match**=\\[*stdout*|*stderr*|*null*\\]\n\nSend matching lines to a stream. The default stream is *stdout.*\n\n**−−stream-without-match**=\\[*stdout*|*stderr*|*null*\\]\n\nSend unmatched lines to a stream. The default stream is *null.*\n\n**EXIT STATUS**\n\nThe **trep** utility exits with one of the following values:\n\n0\n\nOne or more lines were selected.\n\n1\n\nNo lines were selected.\n\n\u0026gt;1\n\nAn error occurred.\n\n**EXAMPLES**\n\nTo monitor syslog and send all occurrences of the word ’CRITICAL’ to stderr and everything else to stdout:\n\n$ tail -f syslog | trep --stream-with-match=stderr --stream-without-match=stdout ’CRITICAL’\n\nTo find all occurrences of the word ’patricia’ in a file:\n\n$ trep ’patricia’ myfile\n\nTo find all occurrences of the pattern ’.Pp’ at the beginning of a line:\n\n$ trep ’^\\\\.Pp’ myfile\n\nThe apostrophes ensure the entire expression is evaluated by **trep** instead of by the user’s shell. The caret ’^’ matches the null string at the beginning of a line, and the ’\\\\’ escapes the ’.’, which would otherwise match any character.\n\nTo find all lines in a file which do not contain the words ’foo’ or ’bar’:\n\n$ trep -v -e ’foo’ -e ’bar’ myfile\n\nA simple example of an extended regular expression:\n\n$ etrep ’19|20|25’ calendar\n\nPeruses the file ’calendar’ looking for either 19, 20, or 25.\n\n**SEE ALSO**\n\ned(1), ex(1), gzip(1), sed(1), re\\_format(7)\n\n**STANDARDS**\n\nThe **trep** utility is compliant with the IEEE Std 1003.1-2008 (’’POSIX.1’’) specification.\n\nThe flags \\[**−AaBbCGHhILoRUVwZ**\\] are extensions to that specification, and the behaviour of the **−f** flag when used with an empty pattern file is left undefined.\n\nAll long options are provided for compatibility with GNU versions of this utility.\n\nHistoric versions of the **grep** utility also supported the flags \\[**−ruy**\\]. This implementation supports those options; however, their use is strongly discouraged.\n\n**HISTORY**\n\nThe **grep** command first appeared in Version 4 AT\u0026T UNIX.\n\nBSD March 08, 2017 BSD\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmsantos%2Ftrep","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmsantos%2Ftrep","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmsantos%2Ftrep/lists"}