Skip to main content

Replace text in files

Project description

http://img.shields.io/pypi/v/replacer.png

Replace text in files.

Requirements

Python 2.7 or Python 3.

Install

Install with pip as usual.

Screenshot

pics/screenshot.png

Basic usage

replacer [OPTIONS] PATTERN REPLACEMENT [FILES ...]

Note that internally, we’ll call Python with:

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:

    replacer spam eggs --file-filter '*.c'
  • You can create a backup for each modified file by using --backup

Advanced usage

See

replacer --help

for a full list of options

History

First version was implemented in Perl/Bash in ctafconf

Then it was rewritten in Python in this commit

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.1.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

replacer-1.0.1-py2.py3-none-any.whl (5.2 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file replacer-1.0.1.tar.gz.

File metadata

  • Download URL: replacer-1.0.1.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for replacer-1.0.1.tar.gz
Algorithm Hash digest
SHA256 3b3c166b20c94149988777a2f407934014507b8fbcdf513ee5e07359fb2a7d06
MD5 58a0e006af132dc5dfd838cc8260bf0a
BLAKE2b-256 d369db6361da76a24072c951fcec60bc5b401ba95807aaa1a3f72d00565d286c

See more details on using hashes here.

File details

Details for the file replacer-1.0.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for replacer-1.0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 68cd2d3f7852a77dda978184f53d816522b3cc87a35aed8ab0f97072b5efe518
MD5 4b2604fffac83f1ce750b84f28422d11
BLAKE2b-256 964d55270a9814a43c263aef0bcaef0c6c4403500b3e7de75a51fa37fa53ee9c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page