# sed script to remove comments in .tex source files. # usage: # sed -f rmtexcmt.sed < input.tex > output.tex # so this here is an sed script, not a shell script. # Copy all lines inside the verbatim-environment without change . /\\begin{verbatim}/,/\\end{verbatim}/ b # Delete lines that begin with a series of non-printable characters # followed by a %-sign. /^[^!-$&-~]*%/d # Delete everything in a line behind and including a percent-sign, if the # percent-sign is not preceeded with a backslash. # For example # job \% here # is copied to the standard output, whereas # job% here # is reduced to # job # on standard output. # Remove a % and all material that follows in the same line, # if it is not preceeded by a backslash and if the percent is not the last # character in that line s/\([^\\]\)%.\{1,\}/\1/ # see also: sed(1) # Richard J. Mathar, Forschungszentrum Rossendorf, 1994-04-17