Manual:Grep.php
MediaWiki version: | ≥ 1.38 |
MediaWiki file: grep.php | |
---|---|
Location: | maintenance/ |
Source code: | master • 1.42.3 • 1.41.4 • 1.39.10 |
Classes: | GrepPages |
Details
grep.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
Option/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
php maintenance/grep.php <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.