https://github.com/ademking/replacestr
Simple utility to replace all occurrences of a string in your files
https://github.com/ademking/replacestr
cli replace-text terminal terminal-cli tool
Last synced: 9 months ago
JSON representation
Simple utility to replace all occurrences of a string in your files
- Host: GitHub
- URL: https://github.com/ademking/replacestr
- Owner: Ademking
- Created: 2022-08-02T21:26:09.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-08-02T21:36:19.000Z (over 3 years ago)
- Last Synced: 2025-06-05T15:47:22.572Z (10 months ago)
- Topics: cli, replace-text, terminal, terminal-cli, tool
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/replacestr
- Size: 4.88 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# replacestr
replacestr is a simple utility that can be used to replace a string in your files. Replacing a string in a file is a common task for developers.
You don't need to know how to write a regex to replace a string in a file. Easy to use and easy to understand.
For example, if you want to replace all occurrences of `foo` with `bar` in a file, you can use the following command:
```
replacestr -f myfile.txt -s foo -r bar
```
## Usage
```
$ replacestr -f myfile.txt -s foo -r bar
$ replacestr -f myfolder/*.txt -s foo -r bar
$ replacestr -f myfolder/**/*.txt -s foo -r bar
$ replacestr -f *.txt -s foo -r bar -i test.txt # ignore case
$ replacestr -f C:/Users/Adem/Myfolder/*.txt -s old -r new -i test.txt
```
To display the help for the tool use the -h flag:
```
$ replacestr -h
```
| Flag (short) | Flag (long) | Description |
| ------------- | --------------------- | ------------------------------------- |
| -f | --files | File(s) or folder to search in. |
| -s | --search | String to search for. |
| -r | --replace | String to replace with. |
| -i | --ignore | File(s) to ignore. |
| -e | --encoding | Encoding to use. Default "utf-8" |
| -q | --silent | Silent mode: no output |
| -h | --help | Show help |
| -v | --version | Show version |
| -p | --pretend | Pretend mode: no changes will be made |
| -a | --about | About replacestr |
| -o | --output | Output file |
## Installation
#### Using npx you can run the script without installing it first:
```
npx replacestr -f myfile.txt -s foo -r bar
```
#### Globally via npm
```
npm install -g replacestr
```
This will install replacestr globally so that it may be run from the command line anywhere.
## Development
Checkout this repository locally, then:
```
$ npm i
$ npm run start -- --help
```
## Changelog
[1.0.0] Initial release.