Shell script implementation quickly generate XML format sitemap instance share _linux Shell

Source: Internet
Author: User

Use the shell to quickly generate a sitemap map file in XML format, which is suitable for small and medium sized websites. In this case, a sitemap file with 12,053 URLs is generated and only spents 4.3 seconds! The shell code is as follows:

Copy Code code as follows:

Cat Sitemap.txt|awk ' begin{print ' <?xml version=\ "1.0\" encoding=\ "utf-8\"?>\n<urlset> "}{print" <url >\n<loc> "$" </loc>\n<lastmod>2014-07-18</lastmod>\n<changefreq>always</ Changefreq>\n</url> "}end{print" </urlset> "}"

Where Sitemap.txt is the collection of all URLs of the site,<lastmod> the date after, you need to change the date when you generated the sitemap file, today is July 18, 2014, so I wrote this.

In fact, with the TXT format sitemap Baidu is also recognized, in order to reflect the powerful shell, I have to put the TXT format toss into XML format!!! The Sitemap.txt content is shown below, with a total of 12,053 URLs.

Final effect and build speed, a total of 12,053 URLs, generate XML sitemap, only spents 4.3 seconds! The speed is still quite fast!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.