1 #!/bin/bash
   2 
   3 cat <<XML
   4 <?xml version="1.0" encoding="utf-8"?>
   5 <opml version="2.0">
   6   <head>
   7     <title>Feeds</title>
   8   </head>
   9   <body>
  10 XML
  11 
  12 sed '/^http/!d' ~/.newsboat/urls |
  13 while read link category title; do
  14     if [[ $last != $category ]]; then
  15         [[ $last ]] && echo '</outline>'
  16         printf '<outline text=%s>\n' "$category"
  17     fi
  18 
  19     printf '  <outline type="rss" xmlUrl="%s" text="%s />\n' \
  20     "$link" "${title:2}"
  21     last=$category
  22 done | sed 's/</    \0/; s/&/\0amp;/g'
  23 
  24 cat <<XML
  25     </outline>
  26   </body>
  27 </opml>
  28 XML