↑ ↓ select, Enter open, Esc close

Extract all URLs from a sitemap.xml

Adjust the values, the command updates live
user@server
curl -s https://example.com/sitemap.xml | grep -oP '(?<=<loc>)[^<]+' | sort -u

Fetches the sitemap and extracts the content of all <loc> elements. Useful for further processing, counting with wc -l or comparing against a crawl. For a sitemap index (WordPress, Yoast, Rank Math), only the child sitemaps appear here.

Note: URLs inside <![CDATA[...]]> are not recognized. To resolve all child sitemaps of an index, see the entry on the sitemap index.

Also searched as

  • extract urls from sitemap.xml
  • list all pages in a sitemap
  • sitemap to url list command line
  • count urls in sitemap

Related one-liners

All in SEO checks

Read first, then run.

The commands on myline.de act directly on servers, files and databases. A wrong path or placeholder can delete data irreversibly or make a server unreachable.

  • All commands are provided without warranty and are not tested on every system.
  • Understand what a command does before running it, and check every placeholder.
  • Make a backup first and, if possible, try it on a test system.
  • You run commands at your own risk. Liability for damages is excluded to the extent permitted by law.