#!/bin/bash
sed -nr '
/\author/ {
:ending
/]|}$/! {
N
b ending
}
s/\author(\{|\[)(.*)(}|])//p
}
' test.tex
Explicação (código do mesmo, mas comentários adicionados):
#!/bin/bash
sed -nr '
# if the line contains the \author string, we are working with it.
/\author/ {
##### this part are needed for multiple line pattern processing
# put a label here. We will be return to this point,
# until we reach line, which have } or ] in the ending.
:ending
# if this line does not ended by } or ].
# It is tell us, that this line continues on the next line.
/]|}$/! {
# Take the next line and append it to the previous line.
# Just join them together.
N
# Go to the ":ending" label
b ending
}
##### ending multiple line pattern processing
# remove the \author word and brackets from line
s/\author(\{|\[)(.*)(}|])//p
}
' test.tex
test.tex
\documentclass{scrartcl}
\usepackage{graphicx}
\title{Test}
\author{Author 1, Author 2, Author 3}
\author[Author 1, Author 2, Author 3]
\author{Author 1,
Author 2,
Author 3}
\author[Author 1,
Author 2,
Author 3]
\begin{document}
\end{document}
saída
Author 1, Author 2, Author 3
Author 1, Author 2, Author 3
Author 1,
Author 2,
Author 3
Author 1,
Author 2,
Author 3