#!/bin/csh -f #(ie run the cshell on this but don't read the .cshrc) echo version = 1.08 of mksubbib 2008 May 01 # 2008 May 01, 1.08: modify so it handles APS # American Physics Society REVTeX4/apsrev.bst # http://authors.aps.org/revtex4/ # 2005 Oct 14, 1.07: otherstuff set to empty as default. # 2005 Aug 6, 1.06: secondary bib database # 2005 Aug 6, 1.05: correct documentation # 2005 Jul 11, 1.04: spelling correction # 2004 Jun 14, 1.03: report number of entries # 2003 Feb 15, 1.02: document upgrade # 2001 Aug 20, 1.01: functional # origin 2001Aug20.22:45:55 # mksubib: make a sub-bibliography. # usage: # For a given paper, paper.tex and paper.bbl, create a subdirectory # and run this script in the sub directory. The resulting # file will be in paper.bib. # required: subbib.bst # The program will attempt to link to it in the delila directory # required: ../paper.bbl # a LaTeX bibliography must be in the directory above. # required: ../all.bib # a bibliography database from which to extract everything must # be in the directory above # If there is one argument, then that is the name of a second # bibliography database. Suppose it is called 'other.bib'. # Then there must be a file called ../other.bib. # The usage would be: # mksubbib other # ***************************************************************************** if !(-f subbib.bst) then lkdelila subbib.bst endif # if the above attempt failed, die: if !(-f subbib.bst) then echo 'could not find subbib.bst' exit endif if !(-f ../paper.bbl) then echo there must be a ../paper.bbl file to use echo as the basis of the bibliography exit endif if !(-f ../all.bib) then echo there must be a ../all.bib file to use echo as the basis of the bibliography exit else if !(-e all.bib) then lk all.bib ../all.bib endif endif if ($#argv == 1) then # The argument is the name of the other bib set other = $1 if !(-f ../$other.bib) then echo There is no ../$other.bib, ignoring argument set otherstuff = "" else set otherstuff = ",other" lk other.bib ../$other.bib endif else set otherstuff = "" endif set keys = paper.tex yes | rm -f paper.aux yes | rm -f paper.bbl yes | rm -f paper.blg yes | rm -f paper.dvi yes | rm -f paper.log yes | rm -f paper.tex echo '\documentclass[12pt]{article}' > $keys echo '\begin{document}' >> $keys echo '\bibliographystyle{subbib}' >> $keys # echo '% (* turn on censor program' >> $keys # original: # grep bibitem ../paper.bbl |\ # sed -e "s/bibitem/cite/" |\ # cat >> $keys # grep bibitem ../paper.bbl |\ set tmp1 = /tmp/`whoami`.mksubbib echo '(* turn on censor program: ' > $tmp1 cat $tmp1 ../paper.bbl |\ # for APS remove material inside [ ] \ sed 's/\[/[[/' |\ sed 's/]/]]/' |\ censor |\ grep 'bibitem' |\ sed -e "s/bibitem/cite /" |\ cat >> $keys # junk: # exit # sed 's/thebibliography/(*/' |\ # # sed -e "s/{/ /" |\ # # fmt -w 1000 |\ # censor |\ # cat # exit # sed 's/\\bibinfo/@/' |\ # #tr '@' '\n' |\ # #grep 'cite' |\ # #tr -d ' ' |\ # cat # exit # censor |\ # cat >> $keys # which censor echo "\bibliography{all$otherstuff}" >> $keys echo '\end{document}' >> $keys echo cat $keys echo latex paper.tex bibtex paper mv paper.bbl paper.bib echo '****************************' echo '* Results are in paper.bib *' echo '****************************' echo "number of entries found:" grep '^@' paper.bib | wc -l echo '****************************'