Replace text in files
Project description
# replacer
Replace text in files.
## Requirements
Python 2.7 or Python 3.
## Screenshot
![screenshot](pics/screenshot.png)
## Basic usage
```bash
replacer [OPTIONS] PATTERN REPLACEMENT [FILES ...]
```
Note that internally, we'll call Python with
```python
re.sub(<PATTERN>, <REPLACEMENT>, line)
```
for each line of every regular file found in the current working directory.
This means you can use fancy backward references with `\1`
* By default hidden files, and files matching
`build-*, .git, .svn, *.py[co], *.[oa] , *.back, *~ , *.so, *.a`
will be ignored
* If `FILES` is given, replacement will be performed on the files given
as argument.
* You can also specify `--file-filter` to specify a pattern to match against
the filenames. For instance, to replace in every `.c` file, use:
```bash
replacer spam eggs --file-filter '*.c'
```
* You can create a backup for each modified file by using `--backup`
## Advanced usage
See :
```bash
replacer --help
```
for a full list of options
## History
First version was implemented in Perl/Bash in
[ctafconf](https://github.com/cgestes/ctafconf/blob/78b92a60bc185b73f95418e3e913e33aae8799f6/bin/replacer)
Then it was rewritten in Python in this
[commit](https://github.com/cgestes/ctafconf/commit/73ea7320a593c1c31125ecff23c86b073f87ea26)
Replace text in files.
## Requirements
Python 2.7 or Python 3.
## Screenshot
![screenshot](pics/screenshot.png)
## Basic usage
```bash
replacer [OPTIONS] PATTERN REPLACEMENT [FILES ...]
```
Note that internally, we'll call Python with
```python
re.sub(<PATTERN>, <REPLACEMENT>, line)
```
for each line of every regular file found in the current working directory.
This means you can use fancy backward references with `\1`
* By default hidden files, and files matching
`build-*, .git, .svn, *.py[co], *.[oa] , *.back, *~ , *.so, *.a`
will be ignored
* If `FILES` is given, replacement will be performed on the files given
as argument.
* You can also specify `--file-filter` to specify a pattern to match against
the filenames. For instance, to replace in every `.c` file, use:
```bash
replacer spam eggs --file-filter '*.c'
```
* You can create a backup for each modified file by using `--backup`
## Advanced usage
See :
```bash
replacer --help
```
for a full list of options
## History
First version was implemented in Perl/Bash in
[ctafconf](https://github.com/cgestes/ctafconf/blob/78b92a60bc185b73f95418e3e913e33aae8799f6/bin/replacer)
Then it was rewritten in Python in this
[commit](https://github.com/cgestes/ctafconf/commit/73ea7320a593c1c31125ecff23c86b073f87ea26)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
replacer-1.0.tar.gz
(5.6 kB
view hashes)
Built Distribution
Close
Hashes for replacer-1.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a30c5d843d1d299d0e065fe527f6599ccaf4f852221dd3afb9ae9adfc4fb7bb6 |
|
MD5 | f48b9a3cef1b060d9e45ca7de07189b2 |
|
BLAKE2b-256 | 3d92eced7b5930d235c7782c56bd393f3450c5088facabddbff7b1f718129b29 |