How to find Confluence pages and then do something

On this page


The CLI provides a number of advanced capabilities to enable actions without scripting. For Confluence, that usually revolves around finding content. This will discuss various techniques that can be used. In many cases, not only do you want to find content, but, you want to do something specific with the content that is found. Like modify it (see also How to automate adding text to Confluence pages) or do something with labels or permissions. The various run actions make this easy to do without scripting.



This search is based on Confluence's search index and is the fastest way to search for simple text similar to goggle searching. It is roughly the same as the search available on the UI for finding text strings. This is the recommended technique for most searches and is supported on getPageList, runFromPageList, getContentList, and runFromContentList.

The most powerful search available from Confluence - see Advanced Searching With CQLvalid cql statement

Find Pages Via Metadata

This means using things like title, page hierarchy, labels, and similar. Use getPageList and runFromPageList actions.

spaceAll spacesRestrict to a single space if specified. Required unless labels is not key, @all
labelsAll pagesRestrict to pages with at least one label.comma separated list of labels
titleAll pagesSubset to related pages based on other parameters
ancestorsoffSet to add all ancestors of the page identified by the title parameterSet using --ancestors
descendentsoffSet to add all descendents of the page identified by the title parameterSet using --descendents
childrenoffSet to add all (direct) children of the page identified by the title parameterSet using --children
Regex pattern for matching titles. If title matches regex and other conditions, it will be included

Search Content

This means actual source (storage format) content of the page which is different than normal index based search normally done on content using CQL. Normally only used for finding text in source that normally would not be in the search index.This is the most accurate way to find specific content on pages, but it is very resource intensive as it must retrieve page source from the server to do the regex pattern matching. This can take minutes to hours depending on the number of pages that need to be searched. Use with caution. If performance is a major issue, there is another, more advanced approach - see How to use SQL to find pages.






Regex pattern for matching storage format content. If page content matches regex and other conditions, it will be included


Finding specific content

confluence --action getPageList --space DEMO --regex2 ".*find this exact content on a page.*"

Legacy Search

Legacy search parameters like search, searchModified, searchTypes, and related have been deprecated for some time and have been removed for version 7.0 in favor of Confluence CQL which is significantly more powerful. See Version 7.0 - Removed Actions and Parameters for more details.

Doing Something

If you need to act on the pages found, the easiest way is to use runFromPageList or runFromContentList to automatically run an action or script of actions for each page found. Things like modifyPage or removePage.


confluence --action runFromPage --space DEMO --regex2 ".*find this exact content on a page.*" --common "--action removePage --id @pageId@"

For more examples, go to How to Globally Search and Modify Content.