#!/bin/sh # Expand article-xml files from a single xml file (publication data) made by BibDesk of OSX # by Hiroshi Hakoyama # POSIX sh # example: # cd www/publications # expand.sh ~/web/papers.xml # make filename=$1 tmpfile=$(mktemp) cp ${filename} ${tmpfile} # some dirty modifications cat ${tmpfile} | (rm ${tmpfile}; sed s/"箱山, 洋."/"箱山 洋"/g > ${tmpfile}) cat ${tmpfile} | (rm ${tmpfile}; sed s/"巌佐, 庸."/"巌佐 庸"/g > ${tmpfile}) cat ${tmpfile} | (rm ${tmpfile}; sed /\>NA\ ${tmpfile}) cat ${tmpfile} | (rm ${tmpfile}; sed /\>NA\./d > ${tmpfile}) cat ${tmpfile} | (rm ${tmpfile}; sed -E 's/\?\./\?/g' > ${tmpfile}) cat ${tmpfile} | (rm ${tmpfile}; sed -E 's/?\./?/g' > ${tmpfile}) # list of the start line-number and end line-number of articles start=`sed -n '/
/=' ${tmpfile}` # make article files set $start i=1 length=$# while test $i -le $length ; do set dummy $start shift $i s=$1 set dummy $end shift $i e=$1 id=`sed -n ${s}p ${tmpfile} | sed -e 's/[^"]*"\([^"]*\)".*/\1/'` sed -n ${s},${e}p ${tmpfile} > $id.xml i=`expr $i + 1` done rm ${tmpfile} exit 0