Need help with replace-in-files-cli?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

sindresorhus
130 Stars 9 Forks MIT License 12 Commits 3 Opened issues

Description

Replace matching strings and regexes in files

Services available

!
?

Need anything else?

Contributors list

# 207
node
exec
test-fr...
nextjs
8 commits
# 28,291
Rust
coreuti...
busybox
Git
1 commit
# 601,517
Node.js
JavaScr...
npm-pac...
1 commit
# 1,341
JavaScr...
Node.js
CSS
node
1 commit
# 6,447
chalk
Svelte
example...
Ada
1 commit

replace-in-files-cli

Replace matching strings and regexes in files

Install

$ npm install --global replace-in-files-cli

Usage

$ replace-in-files --help

Usage $ replace-in-files

Options --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 globbing

Examples $ 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

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.