{"id":13671068,"url":"https://github.com/harthur/replace","last_synced_at":"2025-04-27T14:33:02.776Z","repository":{"id":48031228,"uuid":"1851780","full_name":"harthur/replace","owner":"harthur","description":"Command line search and replace utility","archived":true,"fork":false,"pushed_at":"2019-11-06T17:28:47.000Z","size":54,"stargazers_count":747,"open_issues_count":31,"forks_count":87,"subscribers_count":10,"default_branch":"master","last_synced_at":"2024-11-11T08:43:49.497Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/harthur.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}},"created_at":"2011-06-05T20:47:55.000Z","updated_at":"2024-10-25T10:11:06.000Z","dependencies_parsed_at":"2022-08-12T17:10:17.979Z","dependency_job_id":null,"html_url":"https://github.com/harthur/replace","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/harthur%2Freplace","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harthur%2Freplace/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harthur%2Freplace/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harthur%2Freplace/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/harthur","download_url":"https://codeload.github.com/harthur/replace/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251154276,"owners_count":21544471,"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-08-02T09:00:57.953Z","updated_at":"2025-04-27T14:33:02.428Z","avatar_url":"https://github.com/harthur.png","language":"JavaScript","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","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharthur%2Freplace","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fharthur%2Freplace","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharthur%2Freplace/lists"}