public
Created

Puts loc entry in sitemap_index.xml.gz

  • Download Gist
gistfile1.md
Markdown

Puts loc entry in sitemap_index.xml.gz

##
# Usage: puts_locs `file`
# Puts loc entry in sitemap_index.xml.gz
# 
function _puts_locs() {
  zcat $1 | \
  ruby -anle '$_.sub(/^.*?<loc>/, "").gsub(/<loc>/, "\n").split("\n").each{|l| puts l.sub(/<\/loc>.*$/, "") }'
}

function _path_of() {
  echo $1 | sed 's|.*/sitemap|public/sitemap|' 
}

function puts_locs() {
  for sitemap in `_puts_locs $1`; do
    _puts_locs `_path_of $sitemap`
  done
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.