I have a file test.tex
with content that is similar to this:
\documentclass{scrartcl}
\usepackage{graphicx}
\title{Test}
\author{Author 1, Author 2, Author 3}
\begin{document}
\end{document}
I want to extract every author that is written in the { ... }
. Therefore I did the following:
authors=$(cat test.tex | grep '\author' | tr -d '\author' | tr -d '{' | tr -d '}' )
This code works only for this case. My problem is that
- there could be
[]
instead of{}
- the line could span over multiple lines like the following example
\author{Author 1,
Author 2,
Author 3}
Does anyone know how to solve these two problems?