Text::BibTeX -- bibgrep-like script?

Discussion in 'Perl Misc' started by Michael Friendly, Mar 27, 2013.

  1. I have a bunch of .bib files I use in writing (Ubuntu /Kile). When I
    want to cite a paper, it would be quicker to have a command line utility
    to grep for an author/title keyword to find the key for \cite{} than,
    say to open JabRef or similar and run searches on my various .bib files,
    which live in ~/texmf/bibtex/bib/.

    Is there some script ready made or configurable somewhere to
    use Text::BibTeX to search such a collection of files?


    I did some Googling on this and found bibgrep,
    http://sourceforge.net/projects/bibgrep/, but it is too old and quirky
    to compile from source.
    Michael Friendly, Mar 27, 2013
    1. Advertisements

  2. Can't you load them into SQL with jabRef and then look them up quickly?

    Dr Eberhard Lisse, Mar 29, 2013
    1. Advertisements

  3. FYI/ JFTR: 'SQL' is a query language used by so-called 'relational database
    management systems' (depending on whom you ask, it either means
    'structured query language' or is an abbreviation of the original
    [IBM] name sequel).
    Rainer Weikusat, Mar 29, 2013
  4. Thanks for the reply, but I was looking for a 'live' text-based
    solution. I don't really know
    how to load into SQL with jabRef, but in any case, that would entail
    updating that
    when the .bib files change.

    FWIW, below is a perlish kludge that invokes Tom Christ's old tcgrep
    script with some suitable
    args in my very specific context. I was hoping to replace it with
    something more
    BibTeX-aware and general, perhaps based on Text::BibTeX, to be able to
    search for strings in bibtex keys, authors, titles, ...

    # bibgrep -- Prints entries in your bib file(s) that match search string.
    # USAGE: bibgrep <string> [<files>]

    my $home = $ENV{'HOME'};
    my $tcgrep = "$home/bin/tcgrep";

    # symbolic names for bib files
    my (%BIBFILES) =
    'graphics' => "$home/texmf/bibtex/bib/graphics.bib",
    'statistics' => "$home/texmf/bibtex/bib/statistics.bib",
    'timeref' => "$home/texmf/bibtex/bib/timeref.bib",
    'Rpackages' => "$home/texmf/bibtex/bib/Rpackages.bib",

    ### Arguments

    my $str = shift @ARGV;
    my @files = @ARGV || values %BIBFILES;

    ### Main

    die "USAGE: $0 <string> [<files>]\n" unless $str;
    system("$tcgrep -pTia $str @files");
    Michael Friendly, Mar 29, 2013
  5. Rainer,

    thank you so much for your enlightening comment.

    I use BibDesk on the Mac and thus have not much experience with
    JabRef itself but http://jabref.sourceforge.net/help/SQLExport.php
    shows you what I mean.


    Dr Eberhard Lisse, Mar 30, 2013
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.