On Thu, Nov 18, 2004 at 03:05:50PM -0600, William L. Jarrold wrote: > I need to map through a whole bunch of latex .tex files and remove > everything on a line after a latex comment. > > Maybe I should never use sed and always use perl?
This is an increasingly popular decision, although learning sed might
make you a better Perl programmer.
> ...So, as you seen the first line of sedcmdfile is causing my script
> to be overzealous.
>
> In a nutshell the problem is, how do I, for each line, make it remove
> all %'s and everything after EXCEPT when the % is preceded by a \.
You are matching the preceding character and discarding it. You want to
capture it with a group and print it out:
$ echo '\hline% (+ 14 15 17) = 46 (/ (- 46 44.7) 11.2) = 0.12' | sed -e
's/\([^\\]\)%.*/\1/' -e 's/^%.*//'
\hline
> BUT, I have spent very long on this. I know the g option is for
> greedy but I do not know what o is for.
g replaces multiple occurrences on the same line. You may want to read
_Mastering Regular Expressions_ by Friedl.
--
Andrew Gaul
http://gaul.org/
pgpUSAbhMzwGU.pgp
Description: PGP signature
_______________________________________________ Siglinux mailing list [EMAIL PROTECTED] http://machito.utacm.org/mailman/listinfo/siglinux
