Manual:grep.php
MediaWiki version: | ≥ 1.38 |
MediaWiki file: grep.php | |
---|---|
Location: | maintenance/ |
Source code: | master • 1.42.4 • 1.41.5 • 1.39.11 |
Classes: | GrepPages |
Details
editgrep.php file is a maintenance script that searches the source text of pages for lines matching a given regex, and prints the matching lines to stdout.
This script first fetches all page titles from the database, optionally filtering them by namespace or prefix, and then fetches their text contents to check for the given PCRE regular expression, printing the matching lines.
Options/arguments
editOption/Argument | Description | Required? |
---|---|---|
regex | The regex to search for. | Required |
--prefix | Title prefix. Can be specified more than once. Use e.g. --prefix=Talk: to search an entire namespace.
|
Optional |
--show-wiki -l |
Add the wiki ID to the output | Optional |
--pages-with-matches | Suppress normal output; instead print the title of each page from which output would normally have been printed. | Optional |
Usage
editphp maintenance/run.php grep <regexp> [ --prefix | --show-wiki | pages-with-matches ]
The regular expression will be fed directly to preg_replace(), delimited by curly braces, except if the first character is /
, in which case you are expected to add the end delimiter.
This allows providing a regular expression modifier after the end delimiter.
In MediaWiki version 1.39.10 and earlier, you must invoke maintenance scripts using
php maintenance/scriptName.php
instead of php maintenance/run.php scriptName
.