手机
当前位置:查字典教程网 >脚本专栏 >linuxshell >shell脚本实现快速生成xml格式sitemap实例分享
shell脚本实现快速生成xml格式sitemap实例分享
摘要:用shell快速生成xml格式的sitemap地图文件,中小型网站适用。在本次案例中,生成12053条URL的sitemap文件,仅用时4....

用shell快速生成xml格式的sitemap地图文件,中小型网站适用。在本次案例中,生成12053条URL的sitemap文件,仅用时4.3秒!shell代码如下:

复制代码 代码如下:

cat sitemap.txt|awk 'BEGIN{print "<"1.0" encoding="UTF-8"?>n<urlset>"}{print "<url>n<loc>"$0"</loc>n<lastmod>2014-07-18</lastmod>n<changefreq>always</changefreq>n</url>"}END{print "</urlset>"}'

其中sitemap.txt是网站所有URL的集合,<lastmod>后面的日期,需要修改为你当时生成sitemap文件时的日期,今天是2014年7月18日,所以我写的是这个。

其实用txt格式的sitemap百度也是认可的,为了体现shell功能强大之处,我才在此非得把txt格式的折腾成xml格式的!!!sitemap.txt内容如下图,总共有12053条URL。

shell脚本实现快速生成xml格式sitemap实例分享1

最终效果及生成速度,总共12053条URL,生成xml格式的sitemap,仅用时4.3秒!速度还是相当快的!

shell脚本实现快速生成xml格式sitemap实例分享2

【shell脚本实现快速生成xml格式sitemap实例分享】相关文章:

Shell脚本实现C语言代码行数统计

Shell脚本实现复制文件到多台服务器的代码分享

shell脚本连接、读写、操作mysql数据库实例

shell脚本命令行参数简介

Shell脚本实现关闭多余的tty终端

Shell脚本实现的memcached进程监控

Shell脚本实现的阳历转农历代码分享

shell监控脚本 准备工作分享

Shell脚本实现自动发送邮件的例子

shell脚本监控系统负载、CPU和内存使用情况

精品推荐
分类导航