Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sindresorhus/replace-in-files-cli
Replace matching strings and regexes in files
https://github.com/sindresorhus/replace-in-files-cli
cli-app command-line-tool nodejs npm-package replace replace-in-files replace-text search-and-replace
Last synced: about 1 month ago
JSON representation
Replace matching strings and regexes in files
- Host: GitHub
- URL: https://github.com/sindresorhus/replace-in-files-cli
- Owner: sindresorhus
- License: mit
- Created: 2019-06-12T10:42:59.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2023-05-14T08:12:23.000Z (over 1 year ago)
- Last Synced: 2024-04-14T09:55:54.341Z (7 months ago)
- Topics: cli-app, command-line-tool, nodejs, npm-package, replace, replace-in-files, replace-text, search-and-replace
- Language: JavaScript
- Homepage:
- Size: 19.5 KB
- Stars: 173
- Watchers: 4
- Forks: 12
- Open Issues: 4
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# replace-in-files-cli
> Replace matching strings and regexes in files
## Install
```sh
npm install --global replace-in-files-cli
```## Usage
```
$ replace-in-files --helpUsage
$ replace-in-filesOptions
--regex Regex pattern to find (Can be set multiple times)
--string String to find (Can be set multiple times)
--replacement Replacement string (Required)
--ignore-case Search case-insensitively
--no-glob Disable globbingExamples
$ replace-in-files --string='horse' --regex='unicorn|rainbow' --replacement='🦄' foo.md
$ replace-in-files --regex='v\d+\.\d+\.\d+' --replacement=v$npm_package_version foo.css
$ replace-in-files --string='blob' --replacement='blog' 'some/**/[gb]lob/*' '!some/glob/foo'You can use the same replacement patterns as with `String#replace()`, like `$&`.
```Real-world use-case: [Bumping version number in a file when publishing to npm](https://github.com/sindresorhus/modern-normalize/commit/c1d65e3f7daba2b695ccf837d2aef19d586d1ca6)
The regex should be [JavaScript flavor](https://www.regular-expressions.info/javascript.html).