{"id":20756908,"url":"https://github.com/carlosv2/bash-filter","last_synced_at":"2026-04-25T07:34:57.834Z","repository":{"id":76704679,"uuid":"58331770","full_name":"carlosV2/bash-filter","owner":"carlosV2","description":"Script to easily filter any pipe output","archived":false,"fork":false,"pushed_at":"2016-06-29T15:22:09.000Z","size":9,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-12-26T19:36:10.674Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/carlosV2.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2016-05-08T21:16:39.000Z","updated_at":"2025-09-10T06:45:15.000Z","dependencies_parsed_at":"2023-03-02T14:15:53.706Z","dependency_job_id":null,"html_url":"https://github.com/carlosV2/bash-filter","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/carlosV2/bash-filter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carlosV2%2Fbash-filter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carlosV2%2Fbash-filter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carlosV2%2Fbash-filter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carlosV2%2Fbash-filter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/carlosV2","download_url":"https://codeload.github.com/carlosV2/bash-filter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carlosV2%2Fbash-filter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32254697,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-25T04:23:17.126Z","status":"ssl_error","status_checked_at":"2026-04-25T04:21:53.360Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2024-11-17T09:35:51.348Z","updated_at":"2026-04-25T07:34:57.817Z","avatar_url":"https://github.com/carlosV2.png","language":"Shell","readme":"bash-filter\n===========\n\nThis script provides the missing filter functionality for bash.\n\nInstallation\n============\n\nCheckout the source code:\n```\n$ cd ~\n$ git clone https://github.com/carlosV2/bash-filter.git .bash-filter\n```\n\nLink it to your bash profile file:\n```\n$ echo \"source $(pwd)/.bash-filter/filter.sh\" \u003e\u003e ~/.bash_profile\n```\n\nUsage\n=====\n\nOnce you have installed this script, you then have the function `filter` available to be used as a **pipe**.\nThis function reads the standard input line by line and applies the specified filters to it. The output\nwill be all those lines that match the given filters.\n\nFilters are defined as regular parameter strings. For example, the string `foo` would match any text that\ncontains `foo`. They are also case insensitive so `foo`, `Foo`, `fOo`, `FOO`, etc match among them.\n\nThis command appends some stats at the end. Those stats contains:\n- The number of matching lines\n- The total number of lines\n- The number of (skipped) blank lines\n\nIf you don't want those stats to be appended you can set the `$FILTER_STATS` variable to `false`:\n```\n$ export FILTER_STATS=false\n```\n\nIn case you want the stats but you don't want to color them you can set the `$FILTER_COLORS` variable to `false`:\n```\n$ export FILTER_COLORS=false\n```\n\nYou can also make these variable persistent by writing them into your bash profile:\n```\n$ echo \"export FILTER_STATS=false\" \u003e\u003e ~/.bash_profile\n$ echo \"export FILTER_COLORS=false\" \u003e\u003e ~/.bash_profile\n```\n\n\n+ metacharacter:\n----------------\n\nThe plus (+) metacharacter states that the given filter **must be** contained in the line to match it.\n\nFor example, the filter `+foo` will match a line if there is any occurrence of `foo` in it.\n\n\n- metacharacter:\n----------------\n\nThe minus (-) metacharacter states that the given filter **must not be** contained in the line to match it.\n\nFor example, the filter `-foo` will match a line if there are not occurrences of `foo` in it.\n\n\n~ metacharacter:\n----------------\n\nThe tilde (~) metacharacter states that the given filter should be searched as itself and any morphologic\nderivative of it.\n\nFor example, the filter `~foo` will be searching for occurrences of `foo` and `foos`.\n\nNote: Currently, this functionality is limited to the English language and singular/plural words. It is also\nrecommended to input the word in the singular form for a better performance. However, plural words may also\nwork. If you find an issue with this functionality, please, don't hesitate to open an issue.\n\n\n= metacharacter:\n----------------\n\nThe equals (=) metacharacter states that the given filter should be searched as a standalone word to match it.\n\nFor example, the filter `=foo` will match a line only if `foo` is it preceded and followed by spaces.\n\n\nCombining metacharacters:\n-------------------------\n\nMetacharacters can be combined to form more accurate filters.\nHowever, the combination order must be as follows:\n\n1. =\n2. ~\n3. +/-\n\nExamples:\n- `=-foo`: Will match a line if `foo` is not contained in as a standalone word (it might be contained as part of\nbigger words, though).\n- `=~foo`: Will match a line if either `foo` or `foos` are contained as words.\n- `~-foo`: Will match a line if neither `foo` or `foos` are contained in it. \n- `+~foo`: Because the combination order is broken, this filter will match a line if it contains `~foo` in it (being\n`~` a regular character and not a metacharacter) \n\nBy default, if no `+` or `-` metacharacter is provided, the `+` metacharacter is applied automatically.\n\n\nExamples\n========\n\nImagine we have the following file:\n```\n$ cat bestsellers.txt\nFantastic Beasts and Where to Find Them - J. K. Rowling\nHarry Potter and the Cursed Child - J. K. Rowling\nThe Girl on the Train - Paula Hawkins\nNight School - Lee Child\nThe Reader on the 6.27 - Jean-Paul Didierlaurent\nThe Girl of Ink \u0026 Stars - Kiran Millwood-Hargrave\nThe World's Worst Children - David Walliams\nThe Road to Little Dribbling - Bill Bryson\nCareer of Evil - Robert Galbraith\nHitman Anders and the Meaning of it All - Jonas Jonasson\nLost Girls - Angela Marsons\n```\n\nWe can filter the books that contain `the`:\n```\n$ cat bestsellers.txt | filter the\nFantastic Beasts and Where to Find Them - J. K. Rowling\nHarry Potter and the Cursed Child - J. K. Rowling\nThe Girl on the Train - Paula Hawkins\nThe Reader on the 6.27 - Jean-Paul Didierlaurent\nThe Girl of Ink \u0026 Stars - Kiran Millwood-Hargrave\nThe World's Worst Children - David Walliams\nThe Road to Little Dribbling - Bill Bryson\nHitman Anders and the Meaning of it All - Jonas Jonasson\n\nFound 8 of 11 (0 blank lines)\n```\n\nAlternatively, the `+` metacharacter can be applied with the same result:\n```\n$ cat bestsellers.txt | filter +the\n```\n\nThis filter is matching `them` too but we only want to match the word `the`:\n```\n$ cat bestsellers.txt | filter =the\nHarry Potter and the Cursed Child - J. K. Rowling\nThe Girl on the Train - Paula Hawkins\nThe Reader on the 6.27 - Jean-Paul Didierlaurent\nThe Girl of Ink \u0026 Stars - Kiran Millwood-Hargrave\nThe World's Worst Children - David Walliams\nThe Road to Little Dribbling - Bill Bryson\nHitman Anders and the Meaning of it All - Jonas Jonasson\n\nFound 7 of 11 (0 blank lines)\n```\n\nIf we don't want to match any book from J. K. Rowling, we can use:\n```\n$ cat bestsellers.txt | filter =the -rowling\nThe Girl on the Train - Paula Hawkins\nThe Reader on the 6.27 - Jean-Paul Didierlaurent\nThe Girl of Ink \u0026 Stars - Kiran Millwood-Hargrave\nThe World's Worst Children - David Walliams\nThe Road to Little Dribbling - Bill Bryson\nHitman Anders and the Meaning of it All - Jonas Jonasson\n\nFound 6 of 11 (0 blank lines)\n```\n\nFinally, if we want to match any book about girls, we can use:\n```\n$ cat bestsellers.txt | filter ~girl\nThe Girl on the Train - Paula Hawkins\nThe Girl of Ink \u0026 Stars - Kiran Millwood-Hargrave\nLost Girls - Angela Marsons\n\nFound 3 of 11 (0 blank lines)\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcarlosv2%2Fbash-filter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcarlosv2%2Fbash-filter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcarlosv2%2Fbash-filter/lists"}