{"id":17157309,"url":"https://github.com/eksperimental/prr","last_synced_at":"2025-03-24T14:18:58.190Z","repository":{"id":90320493,"uuid":"42521224","full_name":"eksperimental/prr","owner":"eksperimental","description":"Search and Replace Recursively the Contents of any File","archived":false,"fork":false,"pushed_at":"2015-09-16T06:11:00.000Z","size":300,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-29T19:14:26.522Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eksperimental.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-09-15T13:30:13.000Z","updated_at":"2015-09-15T20:52:46.000Z","dependencies_parsed_at":"2023-03-06T16:45:18.833Z","dependency_job_id":null,"html_url":"https://github.com/eksperimental/prr","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eksperimental%2Fprr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eksperimental%2Fprr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eksperimental%2Fprr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eksperimental%2Fprr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eksperimental","download_url":"https://codeload.github.com/eksperimental/prr/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245284730,"owners_count":20590307,"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":[],"created_at":"2024-10-14T22:08:47.698Z","updated_at":"2025-03-24T14:18:58.169Z","avatar_url":"https://github.com/eksperimental.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"## prr – P(erl) R(eplace) R(ecursively)\n**Search and Replace Recursively the Contents of any File**\n\nSearch recursively strings or regular expressions in the contents of\nall the files in a folder, or any sub-sub-sub-folder, and replace it.\n\n\n## Description\n\nShell script to let you search strings or regular expressions, \nand replace them with string or regular expressions, recursively\nin multiple folders, be able to ignore some, global replacement or\njust only one match, case sensitive or insensitive, ignore files listed\nin popular ignore files such as `.gitignore` or `.hgignore`.\n\n`prr` is a shell script that combines both of the fastest tools\nfor the job:\n* `ag` (the silver searcher) – for searching the files\n* `perl` for actually doing the string substitutions them.\n\n`ag` will find the files that match your `SEARCH PATTERN`,\nand `perl` will do the replacing.\n\n\n### Requirements\n\n* bash\n* [ag – The silver searcher](https://github.com/ggreer/the_silver_searcher/)\n* perl\n\n\n## Usage\n\nBasic usage will be:\n\n```sh\nprr [-cCdDghimuvV] [-o SEARCH_OPTIONS] SEARCH_PATTERN REPLACE_PATTERN [PATH]\n```\n\n## Default Options\n\nBy default, `prr` searches will be case sensitive, they will bot be\nglobal, they won't be multi-line, it will ignore files listed in\nignore-files, it won't follow symlinks.\n\n\n## Disclaimer\n\nPlease, understand before running this command, the nature of this project.\nIt is a command that given a string or a regular expression, it will search recursively in the folders\nand replace inside the files.\nIt can be very destructive if not used with care, but due to it's early stage,\nand since there are no unit tests that can assure that it will avoid\ndangerous situations.\n\nEventhough I have designed this tool with dangers in mind, like trying to let the user know\nwhat are the commands going to be executed.\nBy default (and at least until we reach version 1.0) as a security meassure `prr` will \ndo two things:\n\n1. Sets the **confirm** option (`-c`) on, by default. So you will be asked to confirm and showed the\n  command that will be executed, and the list of files that will be modified.\n\n2. Sets the **backup** options (`-b`) on, by default. Files will be backed-up with the extension current\n  date in the format \".YYYYMMDD_HHMMSS.prr-bak\".\n\nYou can turn off both options by using `-C` and `-B` respectively.\n\nAlternatively you can combine the following options:\n* __debug__ (`-D`): to see how the options are interpreted, the commands being run.\n* __dry-run__ (`-d`): which will only execute the search command and give you a list of files that\n  will be modified.\n* __verbose__ (`v`): to give more details about the action taking place. \n\n\n## Examples\n\n```sh\n# replace the first occurence of apple with banana for every file found\n# recusively under the current dir.\nprr 'Windoze' 'Linux'\n\n# only files in currect dir (no subdirs)\nprr 'apple' 'banana' *.*\n\n# canse insensitive and global:  will replace with REPLICANT all\n# matches of android, no matter the case, under lib/ and test/\nprr -ig 'anDRoid' 'REPLICANT' lib/ test/\n\n# Replace all occurences of \"Mrs.Something\" with \"\u003cMiss Something\u003e\" for\n# all txt files under test/ dir, with the exception of test/drafts/ folder.\nprr -g '\\b(Mrs.)\\s*(\\w+)\\b'  -o '--ignore-dir test/drafts/' '\u003cMiss $2\u003e' test/*.txt\n```\n\n\n## Installation Instructions\n\nPut `[prr](prr)` in your `~/bin/` dir, or source it from the files that\nbash will load automatically when launched, such as `~/.bashrc` or `~/.bash_profile`.\n\n\n## Contributing\n\nThere is always room for error when trying to integrate two different tools into one.\nIf you think something is not working as expected, please\n[create a ticket](https://github.com/eksperimental/prr/issues/new).\n\n\n[Pull requests](https://github.com/eksperimental/prr/pulls) are always welcomed.\n\n\n### Links\n\n* [Github project](https://github.com/eksperimental/prr)\n* [ag – The silver searcher](https://github.com/ggreer/the_silver_searcher/)\n\n\n# TODO\n* Add \"delete backups\" feature.\n* Escape quotes in SEARCH_OPTIONS, SEARCH_PATTERN, REPLACE_PATTERN\n* Once tested thoroughly I will enable the \"follow symlinks\" options.\n  Which I decide to to disable momentarily just to rest on the safe side.\n\n\n### Future plans\n\n* Test it thoroughly with [shunit2](https://github.com/kward/shunit2).\n* Test it with Travis CI.\n* Right now it works with Bash, I will try to make it POSIX compliant,\n  if I see it's doable.\n* Port the \"ag\" command, to use \"find\", in case the former is not installed.\n\n\n## Credits\n\nCreated by **[Eksperimental](https://github.com/eksperimental)**.\n\n\n### License\n\nThis project is released under the Public Domain,\nsee [LICENSE](LICENSE.md) for the full text.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feksperimental%2Fprr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feksperimental%2Fprr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feksperimental%2Fprr/lists"}