0

I want to extract all bibtex items that have a value for the field checked. That is from a file containing the two entries below, I want the second one only. The exact value of the field does not matter.

@proceedings{HPSG2021,
 address = {Frankfurt/Main},
 booktitle = {{Proceedings of the 28th International Conference on Head-Driven Phrase Structure Grammar, Online (Frankfurt\slash Main)}},
 editor = {Müller, Stefan and Melnik, Nurit},
 publisher = {University Library},
 title = {{Proceedings of the 28th International Conference on Head-Driven Phrase Structure Grammar, Online (Frankfurt\slash Main)}},
 year = {2021}}

@incollection{Haider2000a, address = {Amsterdam}, author = {Hubert Haider}, booktitle = {The Derivation of {VO} and {OV}}, checked = {stmue 2021}, doi = {10.1075/la.31.03hai}, editor = {Peter Svenonius}, number = {31}, pages = {45--67}, publisher = {Benjamins}, series = {Linguistik aktuell}, title = {{OV} is More Basic than {VO}}, year = {2000}}

Stefan Müller
  • 6,901
  • 3
  • 29
  • 61
  • 1
    Have you considered biblatex? Such things are much easier there. – samcarter_is_at_topanswers.xyz Nov 17 '22 at 14:58
  • I am using biblatex, but I want to produce a resource for other people and extract all bibtex items that have been verified. Once items are verified I use the field checked and add who did the checking. Now I want to extract all items with the field used. I guess grep magic may do this, but I cannot do this. I could do a Perl program, but ... – Stefan Müller Nov 17 '22 at 15:19
  • see https://tex.stackexchange.com/a/366139/36296 (and https://tex.stackexchange.com/q/41821/36296 for more options, but I would use biblatex) – samcarter_is_at_topanswers.xyz Nov 17 '22 at 15:22
  • OK. This is how to get all cited items from a document. In order to apply this, I would have to know how to cite all items with the checked field. – Stefan Müller Nov 17 '22 at 16:28

1 Answers1

2

You can use bibtool to filter the entries:

bibtool -r biblatex -- select{"checked"} references.bib

Will return only those entries in references.bib, where a key matches checked:

@InCollection{    haider2000a,
  address   = {Amsterdam},
  author    = {Hubert Haider},
  booktitle = {The Derivation of {VO} and {OV}},
  checked   = {stmue 2021},
  doi       = {10.1075/la.31.03hai},
  editor    = {Peter Svenonius},
  number    = {31},
  pages     = {45--67},
  publisher = {Benjamins},
  series    = {Linguistik aktuell},
  title     = {{OV} is More Basic than {VO}},
  year      = {2000}
}
DG'
  • 21,727
  • Thanks! One problem of bibtool is that it does not know collection as a type. Can I do something about this? – Stefan Müller Nov 17 '22 at 16:30
  • A further problem is that features are inherited from other items. So if I have book and incollection and the book has a checked value, all items crossreferencing this item inherit the checked feature. This is intended in normal cases, I guess, but it is not in my case. – Stefan Müller Nov 17 '22 at 16:47
  • For the first thing: use the option -r biblatex to more types. For the second one: you can probably switch crossref off with expand.crossref = off (untested). You might want to peek in the manual for the rather complex configuration options... – DG' Nov 17 '22 at 17:51