file-find-replace-cli
v0.3.1
Published
Replaces text in files, using a JSON file containing matches and replacements
Downloads
11
Maintainers
Readme
file-find-replace-cli
Command-line tool to find and replace text in files.
Installation
npm i -g file-find-replace-cli
Usage
# Replace within a single file
find-replace replace.json -f 'data/users.txt'
# Or within multiple files (uses globs)
find-replace replace.json -f 'data/**/*.txt' -f 'src/**/*.ts'
Syntax
$ file-replace -h
Usage: file-replace <replacementFile> [options]
Command line tool for replacing text in files, using a JSON file containing matches and replacements.
The JSON file must contain an object (or array of objects), each containing a 'find' and 'replace' entry
Arguments:
replacementFile The JSON file containing matches and replacements
Options:
-V, --version output the version number
-f, --file [file...] Path or glob to a file to replace. Can be used
multiple times.
-v, --verbose Turns on verbose mode
-h, --help display help for command
Replacement file
replace.json
contains the replacement info:
[
{
"find": "foo",
"replace": "bar",
"ignoreCase": true // Optional
},
{
"find": "unicorn",
"replace": "🦄"
}
]
The file must contain a single replacement object, or an array of replacements.
{
"find": "<something to find>",
"replace": "<will be replaced with>",
"ignoreCase": false, // optional; false by default
"wholeWord": false // optional; false by default
}