<![CDATA[Commands tagged BibTeX]]> http://www.commandlinefu.com/commands/tagged/2395/bibtex/rss Wed, 18 Jan 2017 18:08:15 +0000 Zend Framework Zend_Feed en-us http://blogs.law.harvard.edu/tech/rss <![CDATA[Put uppercase letters in curly brackets in a BibTeX database]]> michelsberg http://www.commandlinefu.com/commands/view/11770/put-uppercase-letters-in-curly-brackets-in-a-bibtex-database http://www.commandlinefu.com/commands/view/11770/put-uppercase-letters-in-curly-brackets-in-a-bibtex-database $ sed '/^\s*[^@%]/s=\([A-Z][A-Z]*\)\([^}A-Z]\|},$\)={\1}\2=g' literature.bib > output.bib

It is often recommended to enclose capital letters in a BibTeX file in braces, so the letters will not be transformed to lower case, when imported from LaTeX. This is an attempt to apply this rule to a BibTeX database file.

DO NOT USE sed '...' input.bib > input.bib as it will empty the file!

How it works:

/^\s*[^@%]/

Apply the search-and-replace rule to lines that start (^) with zero or more white spaces (\s*), followed by any character ([...]) that is *NOT* a "@" or a "%" (^@%).

s=<some stuff>=<other stuff>=g

Search (s) for some stuff and replace by other stuff. Do that globally (g) for all matches in each processed line.

\([A-Z][A-Z]*\)\([^}A-Z]\|},$\)

Matches at least one uppercase letter ([A-Z][A-Z]*) followed by a character that is EITHER not "}" and not a capital letter ([^}A-Z]) OR (|) it actually IS a "}", which is followed by "," at the end of the line ($).

Putting regular expressions in escaped parentheses (\( and \), respectively) allows to dereference the matched string later.

{\1}\2

Replace the matched string by "{", followed by part 1 of the matched string (\1), followed by "}", followed by the second part of the matched string (\2).

I tried this with GNU sed, only, version 4.2.1.

commandlinefu.com

Diff your entire server config at ScriptRock.com

]]>
Tue, 15 Jan 2013 22:24:17 +0000 http://www.commandlinefu.com/commands/view/11770/put-uppercase-letters-in-curly-brackets-in-a-bibtex-database
http://www.commandlinefu.com/commands/tagged/2395/bibtex/rss
www.commandlinefu.com
crawl=CC-MAIN-2017-04
4282
application/http; msgtype=response
sha1:GUY7M7EISTYYIRA7U2DSAM6R3M6GM2DF
<urn:uuid:17f9a8fd-923a-445c-a140-04f6732a6cef>
2017-01-18T18:08:15Z
104.27.175.104
sha1:V4MQX73YGKWBX7DOWGMNGIZXG43TWILN
<urn:uuid:852f794d-f637-482a-9d0f-fbd07d57a526>
http://www.commandlinefu.com/commands/tagged/2395/bibtex/rss
response
<urn:uuid:365af8f3-fdac-492a-a210-713d0c85aa09>
robots: classic
hostname: ip-10-171-10-70.ec2.internal
software: Nutch 1.6 (CC)/CC WarcExport 1.0
isPartOf: CC-MAIN-2017-04
operator: CommonCrawl Admin
description: Wide crawl of the web for January 2017
publisher: CommonCrawl
format: WARC File Format 1.0
conformsTo: http://bibnum.bnf.fr/WARC/WARC_ISO_28500_version1_latestdraft.pdf