Reference

rpl(1)

replace strings in files

NAME

rpl - replace strings in files

DESCRIPTION

usage: rpl [-h] [--version] [--encoding ENCODING] [-E] [-i] [-m] [-w] [-b] [-q] [-v] [-s] [-e] [-F] [--files] [-x GLOB] [-R] [-p] [-f] [-d] OLD-TEXT NEW-TEXT [FILE ...]

Search and replace text in files.

Text matching the pattern OLD-TEXT is replaced by NEW-TEXT in each FILE. The pattern may match multiple lines.

Filenames may include glob patterns (these must be quoted to avoid being interpreted by the shell), and in particular may use ‘**’ to match all files and zero or more directories and subdirectories. Tilde and environment variable expansion is also performed.

positional arguments:

OLD-TEXT NEW-TEXT FILE `-' or no FILE argument means standard input

options:

-h, --help

show this help message and exit

--version

show program's version number and exit

--encoding ENCODING

specify character set encoding

-E, --extended-regex

use extended regular expression module `regex'

-i, --ignore-case

search case-insensitively

-m, --match-case

ignore case when searching, but try to match case of replacement to case of original, either capitalized, all upper-case, or mixed

-w, --whole-words

whole words (OLD-TEXT matches on word boundaries only)

-b, --backup

rename original FILE to FILE~ before replacing

-q, --quiet

quiet mode

-v, --verbose

verbose mode

-s, --dry-run

simulation mode

-e, --escape

expand escapes in OLD-TEXT and NEW-TEXT [deprecated]

-F, --fixed-strings

treat OLD-TEXT and NEW-TEXT as fixed strings, not regular expressions

--files

OLD-TEXT and NEW-TEXT are file names to read patterns from

-x GLOB, --glob GLOB

modify only files matching the given glob (may be given more than once)

-R, --recursive

search recursively

-p, --prompt

prompt before modifying each file

-f, --force

ignore errors when trying to preserve attributes

-d, --keep-times

keep the modification times on modified files

EXAMPLES

Replace all occurrences of the word ‘F’ with ‘A’ in all files with extension .txt under the grades/ directory:

rpl -w F A 'grades/**/*.txt'

AUTHOR

Written by Göran Weinholt and Reuben Thomas.

COPYRIGHT

Copyright © 2018-2022 Reuben Thomas <[email protected]>
Copyright © 2017 Jochen Kupperschmidt <[email protected]>
Copyright © 2016 Kevin Coyner <[email protected]>
Copyright © 2004-2005 Göran Weinholt <[email protected]>
Copyright © 2004 Christian Häggström <[email protected]>

rpl comes with ABSOLUTELY NO WARRANTY. You may redistribute copies of rpl under the terms of the GNU General Public License. For more information about these matters, see the file named COPYING.

This program was written for Debian as a free replacement for the non-free rpl program by Joe Laffey.

SEE ALSO

find(1), sed(1).

History

--encoding since Debian 11 (Bullseye); --extended-regex since Debian 12 (Bookworm); --files since Debian 11 (Bullseye); --fixed-strings since Debian 11 (Bullseye); --glob since Debian 12 (Bookworm); --match-case since Debian 11 (Bullseye); --recursive since Debian 12 (Bookworm); --version since Debian 11 (Bullseye); -E since Debian 12 (Bookworm); -F since Debian 11 (Bullseye); -R since Debian 12 (Bookworm); -m since Debian 11 (Bullseye); -x since Debian 12 (Bookworm).

--all until Debian 10 (Buster); --license until Debian 10 (Buster); --noglob until Debian 11 (Bullseye); --use-tmpdir until Debian 10 (Buster); -L until Debian 10 (Buster); -a until Debian 10 (Buster); -t until Debian 10 (Buster).