Skip to main content

Aho-Corasick string replacement utility

Project description

Travis CI build status Test code coverage Latest Version

Copyright (c) 2015 Will Roberts <wildwilhelm@gmail.com>

Licensed under the MIT License (see file LICENSE.rst for details).

Search and replace on file(s), with matching on fixed strings.

Install

fsed is written in Python; you can install it with pip:

pip install fsed

Usage

fsed [OPTIONS] PATTERN_FILE [INPUT_FILE [INPUT_FILE2 ...]]

If one or more INPUT_FILEs are specified, fsed reads and concatenates these as its input; otherwise, fsed reads the standard input.

Options:

--pattern-format=FMT
Set FMT to tsv or sed (default is sed) to specify the format of PATTERN_FILE.
-o/--output=OUTFILE
Specifies that the program output should be written to OUTFILE. If this option is not used, fsed writes to standard output.
-w/--words
Makes fsed match only on word boundaries; this flag instructs fsed to append \b to the beginning and end of every pattern in PATTERN_FILE.
--by-line/--across-lines
Sets whether fsed should process the input line by line or character by character; the default is --across-lines.
--slow
Indicates that fsed should try very hard to always find the longest matches on the input; this is very slow, and forces --by-line to be on.
-q
Quiet operation, do not emit warnings.
-v/--verbose
Turns on debugging output.

Note: fsed runs even faster using PyPy:

pypy -m fsed.fsed [OPTIONS] PATTERN_FILE [INPUT_FILE [INPUT_FILE2 ...]]

Pattern File

PATTERN_FILE contains a list of patterns to search and replace in the input; each pattern is listed on a separate line. fsed supports two formats for specifying patterns. The default, sed, specifies strings and their replacements the way the sed utility does:

s/SEARCH/REPLACE/

The character following the s character is the pattern delimiter, and can be any character (it does not have to be a forward slash).

The other format, tsv, specifies patterns using <TAB> characters as delimiters:

SEARCH<TAB>REPLACE

In this format, there must be only one <TAB> character per line.

Patterns can contain escape characters:

\\
Backslash (\)
\a
ASCII bell (BEL)
\b
Word boundary
\f
ASCII formfeed (FF)
\n
ASCII linefeed (LF)
\r
Carriage Return (CR)
\t
Horizontal Tab (TAB)
\v
ASCII vertical tab (VT)

Download files

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

Files for fsed, version 0.5.0
Filename, size File type Python version Upload date Hashes
Filename, size fsed-0.5.0-py2-none-any.whl (18.1 kB) File type Wheel Python version py2 Upload date Hashes View
Filename, size fsed-0.5.0-py3-none-any.whl (18.1 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size fsed-0.5.0.tar.gz (558.9 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page