Sed

Regular Expressions
sed uses POSIX 1003.2 regular expressions, when invoked with the  option.

Command-line Options
-r : use extended regular expressions -i : edit (I)n-place

Examples
change spelling error in all tex files: $ for f in *.tex;do (sed -e "s/rythm/rhythm/g" <$f >$f.sed);mv $f.sed $f;done

funky: replace all "\begin{}" og "\end{}" with "\svin<>" og "\ko<>": $ sed -e 's/\\begin{\([a-z_]*\)}/\\svin<\1>/' -e 's/\\end{\([a-z_]\)}/\\ko<\1>/' svin.tex

fix the tendency of EMacs-users to put "\begin{document}" a.o. in all of their .tex-files: $ sed -e 's/^\\(begin\|end\){document}/% \\1{document}/g' -e 's/\input{preamble}/% \input{preamble}/g' *.tex

convert latex -> plain text: $ sed -e 's/\$//g' -e 's/\\[a-zA-Z]*//g' -e 's/{[a-z_]*}//g' -e 's/ \+/ /g' -e 's/ ,/,/g' idiot.tex

convert LaTeX bibliography file to \cites:

$ sed -e '/^[@].*/!d' -e 's/@alpha:*{\([[:alnum:]_]*\),/\\cite{\1}/g' bibliography.bib    " -e '/^[@].*/!d' ": means: remove all lines that does NOT begin with a '@'    the rest means: replace all "@ {<#1>," with \cite{<#1>}