Article View: comp.text
Article #5929Re: Bibtex search programs ?
From: David F. Kotz
Date: Fri, 24 Feb 1989 16:43
Date: Fri, 24 Feb 1989 16:43
71 lines
2771 bytes
2771 bytes
In article <7348@pyr.gatech.EDU>, mccalpin@loligo (John McCalpin) writes:
> Does anyone have any nice utilities for searching through Bibtex
> files for keywords and such, and then displaying the results nicely?
> I would like to have such a program, but I am not sure it is worth
> the effort to program it since my C is a bit weak....
> ---------------------- John D. McCalpin ------------------------
> Dept of Oceanography & Supercomputer Computations Research Institute
> mccalpin@masig1.ocean.fsu.edu mccalpin@nu.cs.fsu.edu
> --------------------------------------------------------------------
Sure, try this:
#
# looktex - look for a keyword in the references in a BiBTeX file.
#
# David Kotz (dfk@cs.duke.edu)
#
# usage:
# looktex keyword file...
#
# Warning: Any characters in keyword that have meanings in regexps
# used by either sed or egrep must be escaped with a \ (the most
# likely occurrence might be \ itself: use \\). Case is ignored in
# the search, as well as position in the reference.
#
# Multiple keywords may be specified with an egrep alternation format:
# eg looktex 'jones|smith' foo.bib
#
# Actually, any egrep expression is allowed.
# Be sure to quote it properly.
#
# BUGS: Won't notice occurrences of the keyword on the same line as
# the @. Therefore references that have the keyword there only
# cannot be found.
#
set L=/usr/local/public/lib
if ($#argv < 1) then
echo usage: looktex keyword 'file...'
exit 1
endif
set keyword=`echo $1 | tr A-Z a-z`
shift
onintr cleanup
set script=/tmp/looktex$$
# Search for the keyword and get a script for extracting the
# references:
# Cat the files and translate to lower case
# Strip comment lines and comments on lines
# Search for the keyword and all @ lines
# Extract the line number only, plus 'entry' for lines with @
# Convert this output into a sed script
cat $* | tr A-Z a-z \
| sed -e 's/^%.*//' -e 's/\([^\\]\)%.*/\1/' \
| egrep -n "($keyword)"'|^[ ]*@' \
| sed -n -e 's/:[ ]*@.*/ entry/p' -e 's/:.*//p' \
| awk -f $L/looktex.awk > $script
# Now have sed print out the correct entries:
cat $* | sed -n -f $script
cleanup:
rm -f $script
Department of Computer Science, Duke University, Durham, NC 27706
ARPA: dfk@cs.duke.edu
CSNET: dfk@duke
UUCP: decvax!duke!dfk
Technical Details
Message-ID:
<13648@duke.cs.duke.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uflorida!haven!uvaarpa!mcnc!duke!romeo!dfkReferences:
<7348@pyr.gatech.EDU>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uflorida!haven!uvaarpa!mcnc!duke!romeo!dfk From: dfk@romeo.cs.duke.edu (David F. Kotz) Newsgroups: comp.text Subject: Re: Bibtex search programs ? Summary: bibtex search Message-ID: <13648@duke.cs.duke.edu> Date: 24 Feb 89 16:43:58 GMT References: <7348@pyr.gatech.EDU> Sender: news@duke.cs.duke.edu Distribution: usa Lines: 71