{"id":28372312,"url":"https://github.com/brainjs/replace","last_synced_at":"2026-04-02T01:56:53.192Z","repository":{"id":96108925,"uuid":"59958290","full_name":"BrainJS/replace","owner":"BrainJS","description":" Command line search and replace utility","archived":false,"fork":false,"pushed_at":"2016-05-29T18:53:29.000Z","size":48,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-06-10T15:08:16.451Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/BrainJS.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}},"created_at":"2016-05-29T18:38:55.000Z","updated_at":"2019-09-16T01:39:34.000Z","dependencies_parsed_at":null,"dependency_job_id":"1f35f88b-1d4e-4964-801d-cc69c7006f76","html_url":"https://github.com/BrainJS/replace","commit_stats":{"total_commits":66,"total_committers":13,"mean_commits":5.076923076923077,"dds":0.2272727272727273,"last_synced_commit":"04c99bd9a316341b1732739eda029542f027e5a4"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/BrainJS/replace","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BrainJS%2Freplace","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BrainJS%2Freplace/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BrainJS%2Freplace/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BrainJS%2Freplace/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BrainJS","download_url":"https://codeload.github.com/BrainJS/replace/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BrainJS%2Freplace/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261078539,"owners_count":23106482,"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":"2025-05-29T13:43:22.230Z","updated_at":"2026-04-02T01:56:53.142Z","avatar_url":"https://github.com/BrainJS.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# replace\n`replace` is a command line utility for performing search-and-replace on files. It's similar to sed but there are a few differences:\n\n* Modifies files when matches are found\n* Recursive search on directories with -r\n* Uses [JavaScript syntax](https://developer.mozilla.org/en/JavaScript/Guide/Regular_Expressions#Using_Simple_Patterns) for regular expressions and [replacement strings](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String/replace#Specifying_a_string_as_a_parameter).\n\n# Install\nWith [node.js](http://nodejs.org/) and [npm](http://github.com/isaacs/npm):\n\n\tnpm install replace -g\n\nYou can now use `replace` and `search` from the command line.\n\n\n## Examples\n\nReplace all occurrences of \"foo\" with \"bar\" in files in the current directory:\n\n```\nreplace 'foo' 'bar' *\n```\n\nReplace in all files in a recursive search of the current directory:\n\n```\nreplace 'foo' 'bar' . -r\n```\n\nReplace only in test/file1.js and test/file2.js:\n\n```\nreplace 'foo' 'bar' test/file1.js test/file2.js\n```\n\nReplace all word pairs with \"_\" in middle with a \"-\":\n\n```\nreplace '(\\w+)_(\\w+)' '$1-$2' *\n```\n\nReplace only in files with names matching *.js:\n\n```\nreplace 'foo' 'bar' . -r --include=\"*.js\"\n```\n\nDon't replace in files with names matching *.min.js and *.py:\n\n```\nreplace 'foo' 'bar' . -r --exclude=\"*.min.js,*.py\"\n```\n\nPreview the replacements without modifying any files:\n\n```\nreplace 'foo' 'bar' . -r --preview\n```\n\nSee all the options:\n\n```\nreplace -h\n```\n\n## Search\nThere's also a `search` command. It's like `grep`, but with `replace`'s syntax.\n\n```\nsearch \"setTimeout\" . -r\n```\n\n## Programmatic Usage\nYou can use replace from your JS program:\n\n```javascript\nvar replace = require(\"replace\");\n\nreplace({\n  regex: \"foo\",\n  replacement: \"bar\",\n  paths: ['.'],\n  recursive: true,\n  silent: true,\n});\n```\n\n## More Details\n\n### Excludes\nBy default, `replace` and `search` will exclude files (binaries, images, etc) that match patterns in the `\"defaultignore\"` located in this directory.\n\n### On huge directories\nIf `replace` is taking too long on a large directory, try turning on the quiet flag with `-q`, only including the necessary file types with `--include` or limiting the lines shown in a preview with `-n`.\n\n\n## What it looks like\n![replace](http://i.imgur.com/qmJjS.png)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrainjs%2Freplace","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrainjs%2Freplace","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrainjs%2Freplace/lists"}