preplace(1) General Commands Manual preplace(1)
NAME
preplace - replace one string with another in one or more files
SYNOPSIS
preplace [-h(elp)] [-e encoding] [-f filelist] -i INSTRING
[-m max_filesize] -o OUTSTRING [-p(ipe)] [-q(uiet)] [-v(erbose)]
[-z(ero_length_input_processed)] [-Z(ero_length_output_permitted)]
file...
DESCRIPTION
preplace performs string substitutions on text files. This is
accomplished using Python's replace() method.
OPTIONS
-h Print help and quit.
-e encoding
Set the character encoding used by all input files. The default
matches the system default.
-f file_list
Read the names of files to be processed from the specified file.
-i INSTRING
Required option. This is the input string that will be
replaced. It must be of non-zero length.
-m max_filesize
Skip processing of files larger than the specified size to avoid
running out of RAM. The default value is 1073741824 bytes,
i.e., 1 GiB.
-o OUTSTRING
Required option. This is the output string that will be
substituted in place of the input string. A zero-length string
is allowable here.
-p Read the names of files to be processed from stdin.
-q Quiet output. No output commentary will be printed.
-v Verbose output. Commentary about unchanged files will be
printed in addition to the normal commentary about changed
files.
-z Process zero-length input files. Normally preplace will skip
input files with zero length to avoid spurious changes to lock
files and such, but this flag can be specified to permit such
changes.
-Z Permit zero-length output files. Normally preplace will refuse
to generate zero-length output files as a means of protecting
against replacement strings that accidentally contain the
delimiter, but this flag can be specified to permit such
changes.
EXAMPLE
Replace all instances of "big apple" with "small pear" in fruit.txt.
preplace -i 'big apple' -o 'small pear' fruit.txt
Replace all instances of "apple" with "pear" in all text files:
find . -name "*.txt" -print | preplace -p -i 'apple' -o 'pear'
NOTES
The preplace normally works very similarly to the lreplace, but it is
faster and reads entire files into RAM, limiting the size of files can
can be handled.
COPYRIGHT
Copyright (C) 2025-2026 by Brian Lindholm. This program is free
software; you can use it, redistribute it, and/or modify it under the
terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
littleutils 2026 Jan 01 preplace(1)
littleutils 1.4.0 - Generated Wed Feb 18 07:47:48 CST 2026
