Skip to main content

CLI utility for text search / replace.

Project description

psed

CLI utility for text search / replace.

This project is a simple replacement for the sed in Linux. I had enough issues with debugging the regular expressions, especially a few months after they were written, so I have created a replacement in Python. Feel free to use it, but the project aimed to cover my use case so it might not fit everybody. I plan to improve functionality in the future.

Installation and usage

To install, simply run pip install command. You need at least Python 3.6 interpreter.

pip install psed

Usage:

$ psed --help

Usage: psed [OPTIONS]

  Console script for psed.

Options:
  -i, --input TEXT    Path to the input file / directory.  [required]
  -f, --find TEXT     String to find.
  -r, --replace TEXT  String to replace.
  --inplace           Modify the file(s) in place.
  -v, --verbose       Increase verbosity.
  --version           Show the version and exit.
  --help              Show this message and exit.

Usage example

Input file:

[ERROR] Some error
[INFO] Some info
[WARNING] Some warning
[ERROR] Other error
[ERROR] There's a lot of errors
[DEBUG] And one debug

Run psed:

psed --input ./sample \
     --find '\[(ERROR)\]' \
     --find '\[(INFO)\]' \
     --find '\[(WARNING)\]' \
     --replace '[LIGHT_\1]'

Output file:

[LIGHT_ERROR] Some error
[LIGHT_INFO] Some info
[LIGHT_WARNING] Some warning
[LIGHT_ERROR] Other error
[LIGHT_ERROR] There's a lot of errors
[DEBUG] And one debug

History

0.1.0 (2019-08-26)

  • First release on PyPI.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for psed, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size psed-0.1.0-py2.py3-none-any.whl (6.6 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size psed-0.1.0.tar.gz (8.9 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page