Skip to content

Command line (Pro) ​

Searching, replacing and reverting from the terminal, for work that belongs in a deployment or in cron. Every command is a dry run unless you type --dry-run=0.

bash
php craft editrix/run/search --find="old name" --sections=articles
php craft editrix/run/replace --find="old name" --replace="new name" --sections=articles
php craft editrix/run/replace --find="old name" --replace="new name" --dry-run=0
php craft editrix/run/revert 12

Options ​

OptionEffect
--findThe text to find
--replaceThe replacement. Empty deletes the matched text.
--sectionsComma-separated section handles
--entry-typesComma-separated entry type handles
--fieldsComma-separated field handles (title counts)
--sitesComma-separated site ids, or all. Defaults to the primary site.
--elementsComma-separated entry ids, to search only those
--regexTreat --find as a regular expression
--case-insensitiveIgnore case when matching
--whole-wordsMatch whole words only
--linksAlso search and replace the href and src of links and images in rich text
--preserve-caseGive the replacement the capitalisation of what it replaces
--dry-run1 (default) reports only. 0 changes content.
--userThe user a replace is logged under: id, username or email. Defaults to the first admin.
--limitHow many matches to list. Default 20.
--forceOn revert, also overwrite values edited since

The same limits apply as in the control panel: the rows per replace of your edition, protectedFields and protectedSections, and Craft's permissions for the --user the command acts as. The default user is the first admin, who may edit everything. A replace from the command line is logged and can be reverted from Logs & History.

A plugin byBrand IndustryBrand Industry

Editrix is released under the Craft License. One license covers one production site.