lreplace(1) General Commands Manual lreplace(1)
NAME
lreplace - replace one string with another in one or more files
SYNOPSIS
lreplace [-h(elp)] [-d delimiter] -i INSTRING -o OUTSTRING [-q(uiet)]
[-v(erbose)] [-z(ero_length_input_processed)]
[-Z(ero_length_output_permitted)] file...
DESCRIPTION
lreplace performs string substitutions on text files. This is
accomplished using the sed and tempname utilities.
OPTIONS
-h Print help and quit.
-d DELIMITER
Set the sed delimiter. The default value is '#'.
-i INSTRING
Required option. This is the input string that will be
replaced. It must be of non-zero length.
-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.
-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 lreplace 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 lreplace 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:
lreplace -i 'big apple' -o 'small pear' fruit.txt
Replace all instances of "apple" with "pear" in all text files:
find . -name "*.txt" -print0 | xargs -0 lreplace -i 'apple' -o
'pear'
NOTES
The lreplace normally works very similarly to the preplace, but it is
slower and can handle files of arbitrary sizes.
SEE ALSO
sed(1), tempname(1)
COPYRIGHT
Copyright (C) 2004-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 lreplace(1)
littleutils 1.4.0 - Generated Wed Feb 18 07:26:12 CST 2026
