[BACK]Return to expand.sh CVS log [TXT][DIR] Up to [local] / web

File: [local] / web / expand.sh (download)

Revision 1.6, Sun Nov 18 13:15:44 2018 JST (5 years, 5 months ago) by hako
Branch: MAIN
CVS Tags: HEAD
Changes since 1.5: +4 -4 lines

basename

#!/bin/sh
# $Id: expand.sh,v 1.6 2018/11/18 04:15:44 hako Exp $
# Expand article-xml files from a single bibtex file (publication data) made by BibDesk of OSX
# by Hiroshi Hakoyama
# POSIX sh
# example:
# cd www/publications
# expand.sh $HOME/web/bibtex/papers.bib
# make

filename=$1
tmpfile=$(mktemp)
cp ${filename} ${tmpfile}
tmpfile_2=$(mktemp)

# select the template file
case $(basename $filename) in
  papers*)
    template="$HOME/web/BibDesk_Templates/sblg-article-template.xml"
    ;;
  books*)
    template="$HOME/web/BibDesk_Templates/sblg-incollection-template.xml"
    ;;
  conference*)
    template="$HOME/web/BibDesk_Templates/sblg-conference-template.xml"
    ;;
  *)
    template="$HOME/web/BibDesk_Templates/sblg-proceedings-misc-techreport-template.xml"
    ;;
esac

# list of the start line-number and end line-number of articles
start=`sed -n '/@.*{/=' ${tmpfile}`
end=`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
  sed -n ${s},${e}p ${tmpfile} > ${tmpfile_2}
  bib2xml.sh ${template} ${tmpfile_2}
  i=`expr $i + 1`
done

rm ${tmpfile}
rm ${tmpfile_2}

exit 0