Annotation of web/expand.sh, Revision 1.5
1.1 hako 1: #!/bin/sh
1.5 ! hako 2: # $Id: expand.sh,v 1.4 2018/11/18 03:17:19 hako Exp $
1.4 hako 3: # Expand article-xml files from a single bibtex file (publication data) made by BibDesk of OSX
1.1 hako 4: # by Hiroshi Hakoyama
5: # POSIX sh
6: # example:
7: # cd www/publications
1.4 hako 8: # expand.sh $HOME/web/bibtex/papers.bib
1.1 hako 9: # make
10:
1.5 ! hako 11: filename=$(basename $1)
1.1 hako 12: tmpfile=$(mktemp)
13: cp ${filename} ${tmpfile}
1.4 hako 14: tmpfile_2=$(mktemp)
1.1 hako 15:
1.4 hako 16: # select the template file
17: case "$filename" in
18: papers*)
19: template="$HOME/web/BibDesk_Templates/sblg-article-template.xml"
20: ;;
21: books*)
22: template="$HOME/web/BibDesk_Templates/sblg-incollection-template.xml"
23: ;;
24: conference*)
25: template="$HOME/web/BibDesk_Templates/sblg-conference-template.xml"
26: ;;
27: *)
28: template="$HOME/web/BibDesk_Templates/sblg-proceedings-misc-techreport-template.xml"
29: ;;
30: esac
1.5 ! hako 31: echo $template
1.1 hako 32: # list of the start line-number and end line-number of articles
1.4 hako 33: start=`sed -n '/@.*{/=' ${tmpfile}`
34: end=`sed -n '/}}/=' ${tmpfile}`
35:
1.1 hako 36: # make article files
37: set $start
38: i=1
39: length=$#
40: while test $i -le $length ; do
41: set dummy $start
42: shift $i
43: s=$1
44: set dummy $end
45: shift $i
46: e=$1
1.4 hako 47: sed -n ${s},${e}p ${tmpfile} > ${tmpfile_2}
48: bib2xml.sh ${template} ${tmpfile_2}
1.1 hako 49: i=`expr $i + 1`
50: done
51:
52: rm ${tmpfile}
1.4 hako 53: rm ${tmpfile_2}
1.1 hako 54:
55: exit 0