HOWTO: replace references

Let’s assume that you have a latex project with multiple .tex files.
You want to search all the .tex files in a directory and replace the bibtexkey WSBT11 with Wallace2001.

First, you can search for all the files containing key:

grep --include=\*.tex -rn . -e 'WSBT11'

Then, replace WSBT11 with Wallace2001:

sed -i -- 's/WSBT11/Wallace2011/g' **/*.tex(D.)

*Note: I am using zsh on my Mac and as a side effect all the files get a new line added to the end of the file. Moreover, copies of the files with the extension .tex– are created.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.