replace

replace changes words inside files, not their filenames. Its default output is a preview: file names and replacement counts. Run the same command with -w only after checking those matches. For a single file, provide its path; for subfolders, select a directory and add -r.

DevelopmentVersion 1.1.5Stable
lil-terminal

Overview

Use -e txt,php for extensions or -g "*.php" for a filename mask. -i ignores case for plain-text matches. -p expects a full PHP regular expression, including delimiters such as ~draft~. The -a option includes normally skipped dependency and cache folders.

Preview the scope before writing

Add -b with -w to preserve the previous file as .bak, then .bak-001 and so on. Existing backups are never overwritten, and recursive scans skip them. Files above 4 MiB and binary files are skipped; there is a 5000-file scan limit.

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

See the effect before writing

replace changes words inside files, not their filenames. Its default output is a preview: file names and replacement counts. Run the same command with -w only after checking those matches. For a single file, provide its path; for subfolders, select a directory and add -r.

Target only the files you mean

Use -e txt,php for extensions or -g "*.php" for a filename mask. -i ignores case for plain-text matches. -p expects a full PHP regular expression, including delimiters such as ~draft~. The -a option includes normally skipped dependency and cache folders.

Recoverable changes

Add -b with -w to preserve the previous file as .bak, then .bak-001 and so on. Existing backups are never overwritten, and recursive scans skip them. Files above 4 MiB and binary files are skipped; there is a 5000-file scan limit.

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 changes in a 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.5
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 changes in a file
cd \sandbox | replace draft published workspace/replace.txt
Preview                2 replacements in 1 file
workspace/replace.txt  2

Write                  use -w to apply changes
Apply a reviewed change
replace draft published \sandbox\workspace\replace.txt -w
Replaced                   2 occurrences in 1 file
workspace/replace.txt      2

Find text regardless of case
replace DRAFT published \sandbox\workspace\replace.txt -i
Preview                2 replacements in 1 file
workspace/replace.txt  2

Write                  use -w to apply changes
Use a regular expression
replace "~draft~" published \sandbox\workspace\replace.txt -p
Preview                2 replacements in 1 file
workspace/replace.txt  2

Write                  use -w to apply changes
Limit to text extensions
replace draft published \sandbox\workspace -r -e txt
Preview                2 replacements in 1 file
workspace/replace.txt  2

Write                  use -w to apply changes
Filter by file name
replace draft published \sandbox\workspace -r -g "*.txt"
Preview                2 replacements in 1 file
workspace/replace.txt  2

Write                  use -w to apply changes
Write with a backup
replace draft published \sandbox\workspace\replace.txt -w -b
Replaced                   2 occurrences in 1 file
workspace/replace.txt      2

Backups                    1
workspace/replace.txt.bak
Include dependency folders
replace draft published \sandbox\workspace -r -a -e txt
Preview                3 replacements in 2 files
workspace/replace.txt  2
workspace/vendor/review.txt  1

Write                  use -w to apply changes
Preview a directory
replace draft published \sandbox\workspace
Preview                2 replacements in 1 file
workspace/replace.txt  2

Write                  use -w to apply changes
Handle missing target
replace draft published \sandbox\missing.txt
Path not found
Reject an invalid regex
replace draft published \sandbox\workspace\replace.txt -p
Invalid regular expression
Keep a second numbered backup
replace draft published \sandbox\workspace\replace.txt -w -b | replace published final \sandbox\workspace\replace.txt -w -b
Replaced                   2 occurrences in 1 file
workspace/replace.txt      2

Backups                    1
workspace/replace.txt.bak

Replaced                   2 occurrences in 1 file
workspace/replace.txt      2

Backups                    1
workspace/replace.txt.bak-001

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.52026-10-31

Safe numbered backups

Directory scans skip generated backup names (.bak, .bak-001, etc.); explicit backup paths remain available.