file-find-replace-cli
TypeScript icon, indicating that this package has built-in type declarations

0.3.1 • Public • Published

Build status

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
}

Dependents (0)

Package Sidebar

Install

npm i file-find-replace-cli

Weekly Downloads

2

Version

0.3.1

License

MIT

Unpacked Size

19.6 kB

Total Files

28

Last publish

Collaborators

  • sandervandriel