0

I am writing a script in order to automate the addition of new bib entries in my bibliography database. In order to achieve that I use the command:

curl -LH "Accept: application/x-bibtex" http://dx.doi.org/10.1038/nrd842

which in turn produces the output:

@article{Atkins_2002,
        doi = {10.1038/nrd842},
        url = {https://doi.org/10.1038%2Fnrd842},
        year = 2002,
        month = {jul},
        publisher = {Springer Science and Business Media {LLC}},
        volume = {1},
        number = {7},
        pages = {491--492},
        author = {Joshua H. Atkins and Leland J. Gershell},
        title = {Selective anticancer drugs},
        journal = {Nature Reviews Drug Discovery}
    }

I used sed to change the urlencoded backslash but I can't get why the month entry is not an integer. Biblatex says that the month entry must be an integer. Is there any command line tool that can outputs the bibliography with the correct month entry?

Bernard
  • 271,350
ado sar
  • 203
  • Is something like sed -E -e 's/(^\s*month\s*=\s*)\{jan\}/\1{1}/' [...] -e 's/(^\s*month\s*=\s*)\{jul\}/\1{7}/' [...] (filling in the other months for [...]) too cumbersome? – frabjous Jun 18 '22 at 21:53
  • @frabjous This is what I thought but I was wondering if there was something less cumbersome. – ado sar Jun 18 '22 at 22:19
  • 1
    How about n=0; for m in jan feb mar apr may jun jul aug sep oct nov dec ; do let n++ ; sed -i -E -e 's/(^\s*month\s*=\s*)\{'"$m"'\}/\1{'"$n"'}/' filename.bib ; done? – frabjous Jun 18 '22 at 22:25
  • @frabjous What (^ does? – ado sar Jun 18 '22 at 22:45
  • 1
    In extended mode (-E) parentheses are used for capture groups. Basically everything from the ( to ) is saved as a capture group which I then refer to in the replacement as \1. The ^ means "the start of the line": which I put in partly to guarantee there's nothing but whitespace before "month" on the line, partly for speed as it reduces the ranges it needs to search dramatically. In this particular case (^ and ^( would be interchangeable. – frabjous Jun 18 '22 at 22:58
  • Software-generated .bib entries often have quality issues: https://tex.stackexchange.com/q/386053/35864. I'd venture that the incorrect month field is only a start. – moewe Jun 20 '22 at 05:04

0 Answers0