#!/bin/awk --file # File : bib2aux.awk # Descr : extract all keys from a bib file into an aux file which then # can be processed with bibtex to generate a formatted listing of all # bib entries # Author : Andreas Abel # Created: 2005-10-13 # We only treat entries of a bib-file which start with a line # # @ { , # # and write the key into the output as # # \citation{} # # We can safely assume that all bib-entries follow the above convention, # although I am not sure whether the has be to on the same line as # the . # # Following Gerd Neubauer's documentation for bibtool, a key might not # contain whitespaces and any of # # " # % ' ( ) , = { } BEGIN { printf ("% Created by bib2aux.awk\n"); FS = "[ \t{,]+"; # treat { and , as field separators plus whitespaces } /\@.+\{.+,/ { printf ("\\citation{%s}\n", $2); } # The matching idea did not work, it seems that awk does not support # the emacs-style bracketing \(...\) and \1,\2 ... # TRASH: # printf ("1%s2%s3%s4%s5", $1, $2, $3, $4, $5) ; # if ( $0 ~ /\(.+\)/ ) { # if ( $0 ~ /[ \t\n]*[@].+\{\(.+\),/ ) { # if ($0 ~ /[ \t\n]*\@.+\{[ \t\n]*\([^ \n\t"#%'(),={}]+\){[ \t\n]*,/) { # printf ("\\citation{%s}\n", $1); # }