Giter VIP home page Giter VIP logo

find-and-replace's Introduction

find-and-replace

Like sed but defaults to fixed strings instead of regexes. Substitution is done on the whole file instead of line-by-line (like sed with the -z flag).

Rationale:

Substituting fixed strings with sed which only offers regex substitution is a massive pain. Also, often we want to replace strings that spread across multiple lines, though that works with sed with the -z flag.

Installation:

./setup && ./build && sudo ./install

Usage:

find-and-replace [FIND] [REPLACE] [OPTIONS]... [FILES]...
Options:
  -g
    Replace all occurrences of FIND with REPLACE.
    The default replaces only the first occurrence.
  -i[SUFFIX]
    Replace files in-place. The default is printing to stdout.
    If SUFFIX is provided, backup the original file suffixed with SUFFIX.
  -r
    Recurse on the directories in FILES.
  --include GLOB
    File glob to match when -r is used. Glob is a wildcard.
  --exclude GLOB
    The reverse of --include. Skip files that match glob.
    This applies to the passed command line files.
  -F
    Treat FIND as a fixed-string. This is the default.
  -R
    Treat FIND as a regex.
  -E
    Use POSIX Extended Regular Expressions syntax.
    REG_EXTENDED is passed as the cflag to regexec.
  -I
    Ignore case.
    REG_ICASE is passed as the cflag to regexec.

FIND and REPLACE shall be placed in that exact order.

\b, \f, \n, \r, \t, \v, and \ooo (octal) in FIND and REPLACE will be unescaped.
Otherwise, unescaped backslashes will be removed, so use two backslashes for a backslash.
For example: '\\(this\\)' and '\\1' instead of '\(this\)' and '\1', unlike what
you would do with sed.

Filenames shall not start with - as they will be interpreted as a flag.

Single character flags starting with a single dash can be combined.
For example: -EI is equal to -E -I.

-E (Extended Regex) and -I (ignore case) imply -R (Regex), so using -E or -I automatically
enables -R.

If no file was passed, read from stdin.

find-and-replace's People

Contributors

iakobvs avatar

Watchers

 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.