summaryrefslogtreecommitdiff
path: root/biblio/bibtex/utils/misc/bibfind
diff options
context:
space:
mode:
Diffstat (limited to 'biblio/bibtex/utils/misc/bibfind')
-rw-r--r--biblio/bibtex/utils/misc/bibfind38
1 files changed, 38 insertions, 0 deletions
diff --git a/biblio/bibtex/utils/misc/bibfind b/biblio/bibtex/utils/misc/bibfind
new file mode 100644
index 0000000000..f2ac1a3760
--- /dev/null
+++ b/biblio/bibtex/utils/misc/bibfind
@@ -0,0 +1,38 @@
+#!/usr/bin/perl
+#
+# bibfind -- Prints entries in your bib file that match search string.
+#
+# USAGE: bibfind <string> [<file>]
+#
+# Note:
+# Place bibfind in ~/bin, then chmod +x bibfind, then edit bibfind to change
+# the default bib file (see the variable $bibfile on line 29).
+#
+# 2001-07-05, Oyvind.Breivik@dnmi.no
+#
+
+### Arguments
+
+ my ($str,$file) = @ARGV;
+
+### Locals
+
+ my @paragraphs;
+ my $home;
+ my $bibfile;
+
+### Main
+
+ die "USAGE: $0 <string> [<file>]\n" if $#ARGV < 0;
+ $/ = ''; # $INPUT_RECORD_SEPARATOR set to read paragraphs
+ $home = $ENV{"HOME"};
+ $bibfile = "$home/dok/tex/bibtex/Breivik.bib"; # Default bibtex file
+ $file = $bibfile if ($#ARGV < 1);
+
+ open(FILE, $file) or die "ERROR: Can't open $file";
+ print "$file\n";
+ @paragraphs = <FILE>; # Slurp up file by paragraph
+
+ foreach (@paragraphs) {
+ print if /$str/i; # Case ignored, if wanted, remove trailing i.
+ }