replace

replace previews text or regular-expression substitutions across selected files before it writes anything. Scope can be narrowed by path, extension or glob; -w is required to apply changes.

DevelopmentVersion 1.1.4Stable
lil-terminal

Overview

Use replace when the same textual change belongs in more than one place, but keep the first run as a preview. Narrow the target set, inspect file and occurrence counts, then repeat the same command with -w when the plan is correct.

Preview the scope before writing

Start with a command such as replace debug false config -r -e ini. Nothing is written yet. Add -w only after the preview names the expected files; add -b when a .bak copy is useful before a bulk change.

Syntax

lil-terminal
replace <old> <new> [path] [options]

Reference

replace <old> <new>

preview replacements in files of the current directory

replace <old> <new> <file>

preview replacements in one file

replace <old> <new> <dir> -r

preview replacements recursively inside a directory

-w

write the planned changes atomically

-i

match plain text without case sensitivity

-p

treat <old> as a complete PHP regular expression

-e <exts>

limit extensions, for example php,js,css or tar.gz

-g <glob>

limit basenames with a glob such as *.php

-b

create .bak copies before writing

-a

include vendor, node_modules, VCS and cache directories

Choosing the scope

Without a path, the current directory is used. A directory is scanned only at its top level unless -r is present. -e <exts> filters by extension and -g <glob> by basename. Common dependency, VCS and cache directories are skipped unless -a is explicit; symbolic links are never processed.

Preview and write

Preview is the default and reports how many replacements would occur in each matching file. Repeat the same command with -w to write. -b creates a .bak copy first and stops if that backup already exists. -i applies to plain-text matching; -p expects a complete PHP regular expression including delimiters.

Limits and safety

At most 5000 files are scanned in one run, files larger than 4 MiB and binary files are skipped, and at most 500 changed files are listed in the report. Writes use a temporary file and rename so a successful replacement does not leave a partially written target.

Interactive sandbox preview

Run the prepared examples directly on the page. Their results are prebuilt and shown in the browser; no terminal command is executed on the server.

Preview replacements in one file

Install and manage

Install the current compatible version. Choose Base for the complete feature set or Minimum for the reduced package; use upgrade to update a module that is already installed.

Base and Minimum are two packages of the same current module release, not separate command versions.

Base package

Install the complete package with local command reference and every published mode.

install replace
Minimum package

Install the reduced package. Local reference is omitted; help <cmd> -i opens the current server reference.

install replace -m
Exact public version

Install exactly this published version.

install replace -v 1.1.4
Check or update

Ask upgrade to check compatibility and replace the installed block only when needed.

upgrade replace
Remove module

Remove the extension block while leaving the core and unrelated modules intact.

install replace -u

Examples

Examples are copyable command lines, not actions executed by this website. Review paths, permissions and destructive flags before running them on a real project.

Preview replacements in one file
cd \sandbox | replace beta "beta reviewed" workspace/original.txt
Preview      workspace/original.txt
Files        1
Matches      1
Would write  1
Write the planned changes atomically
replace alpha omega workspace/original.txt -w
Write     workspace/original.txt
Files     1
Replaced  1
Match plain text without case sensitivity
replace ALPHA omega workspace/original.txt -i
Preview      workspace/original.txt
Case         insensitive
Matches      1
Would write  1
Treat <old> as a complete PHP regular expression
replace "~beta.*~" "beta" workspace/original.txt -p
Preview      workspace/original.txt
Mode         regex
Matches      1
Would write  1
Limit extensions, for example php,js,css or tar.gz
replace debug false config -r -e ini
Preview      config
Extensions   ini
Files        1
Matches      1
Would write  1
Limit basenames with a glob such as *.php
replace alpha omega workspace -r -g "*.txt"
Preview      workspace
Mask         *.txt
Files        3
Matches      2
Would write  2
Create .bak copies before writing
replace debug false config -r -w -b
Write     config
Files     2
Replaced  2
Backups   2
Include vendor, node_modules, VCS and cache directories
replace vendor_name package_name . -r -a
Preview      .
Hidden       included
Matches      1
Would write  1
Handle a missing target path
replace absent present missing.txt
File not found: missing.txt

File used in this example: sandbox/workspace/replace.txt

The example uses a file or directory from the protected /sandbox/ documentation workspace.

status=draft
owner=lil
status=draft

Related documentation

Current public release

v1.1.42026-08-13

Clearer text-replacement reference

Clarifies that replace edits text inside files, with shorter <old>/<new> placeholders and unchanged preview-first safety.