Eu suponho que você tenha um ambiente Bash padrão * nix disponível.
#!/bin/sed -f
# Match pattern that begins ("^") with "\teil...", capture what's
# between braces thru parentheses.
/^\teilseiten\({.*}\){/ {
# And...
# Copy pattern on hold space ("h"); substitute pattern with new
# lines, with captured text at the end, retrieved by backreference
# (""); process next line ("n").
h; s//\begin{mycolumns}\n \begin{mycolumn}/; n
# Set a label.
: loop
# Add two spaces at the beginning of line ("^"); process next line
# ("n").
s/^/ /; n
# If line contains "\end{tiny}" add two spaces in front, a newline
# ("\n") at the end of it ("&"), and the new line " \end{my...".
s/.*\end{tiny}/ &\n \end{mycolumn}/
# If no substitution was succesful after last read line ("n")
# (i.e. the "s" above wasn't triggered), jump to label.
T loop
# Process next line ("n"); if braces "}{" are at beginning of line
# ("^"), then copy ("g") hold space to pattern space (see "h"
# above); capture content between braces, substitute pattern with
# line "\begin{my..." and captured string "" at the end.
n; /^}{/ {
g; s/.*\({.*}\){/\begin{mycolumn}/
}
# If the above substitution was successful (i.e. "}{" was
# matched), jump to label.
t loop
# Substitute brace with "\end{my...".
s/^}$/\end{mycolumns}/
}
Cole o script no arquivo lanext.sh
e torne-o executável por:
chmod +x lanext.sh
Execute desta forma:
./lanext.sh test.txt
Em que test.txt
detém o código que precisa ser substituído.