sreplace 0.9.0

Command line program to replace strings in files.
sreplace-0.9.0 is not a library.

sreplace

Command line program to replace strings in files.

This is a rewritting of an old project of mine, from C++ to rust.

Usage

Search for a pattern in a file and replace it by a string. Support UTF-8 encoding

Usage: sr [OPTIONS] <PATTERN> <REPLACEMENT> <PATH>

Arguments:
  <PATTERN>      The pattern to look for, string by default, may be a regular expression
  <REPLACEMENT>  The replacement string
  <PATH>         The path to the file or directory

Options:
  -e, --regex                  Search pattern as a regular expression (slower)
  -t, --extension <EXTENSION>  Replace only the files with the specified extension
  -d, --dry-run                Do not modify any file, just print what would happen
  -v, --verbose...             More output per occurrence
  -q, --quiet...               Less output per occurrence
  -h, --help                   Print help

Installation

  • install rust
  • clone this project
  • from this project root folder, execute:
cargo build --release
  • the ready to use sr executable is built in target/release/ folder

Move this executable in one of your favorite folders available in your PATH.

Testing

To execute unit tests:

cargo test

License

GPL v3

Coming soon

  • replacements in folders, not only regular file
  • handle end of line according to OS (linux, MacOS, windows)