GithubHelp home page GithubHelp logo

psed's Introduction

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

psed's People

Contributors

aklajnert avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.