#!/usr/bin/gawk -f # modification d'un fichier bbl donné en entrée (standard) par le fichier lipnbib.bbl (les références sont substitués) # echo $0 ; # BEGIN { LIPNBBLFILE="main.bbl" } { if ( $0 ~ /^\\lipnbibitem{/ ) { bool = 0 ; sub (/^\\lipnbibitem{/, ""); split($0,a,"}{"); # print "ind=" a[1] " ref=" a[2] ; while ((getline tmp < LIPNBBLFILE) > 0) { if ( tmp ~ /^\\lipnbibitem{/ ) { sub (/^\\lipnbibitem{/,"",tmp); split(tmp,b,"}{"); if (a[2] == b[2]) { print "\\lipnbibitem{" b[1] "}{" b[2] "}{" ; bool = 1 ; } } } ; close (LIPNBBLFILE) ; if ( bool == 0 ) print "\\lipnbibitem{" a[2] "}{" a[2] "}{" ; # cas où une citation n'est pas référencée dans la bib } else print $0 }