help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: grep can help?


From: LEE Sau Dan
Subject: Re: grep can help?
Date: 21 Apr 2004 18:52:10 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2

>>>>> "FCC" == FCC  <address@hidden> writes:

    FCC> Hello all, Here is what I am trying to do: I have fortran90
    FCC> source files full of comments everywhere. A comment starts
    FCC> with ! and continues until the end of line, and it can start
    FCC> in the middle of a line after some code that gets compiled.

...


    FCC> Then came the idea to use grep. Now, grep --regexp="\B!.*"
    FCC> --only-matching --no-filename efe2.f90 successfully displays
    FCC> all comments in the file efe2.f90, regardless of whether thay
    FCC> appear by themselves on a line or they share the same line
    FCC> with legitimate code, thanks to the option
    FCC> --only-matching. Now, what I need is exact inverse, so I use:
    FCC> grep --invert-match --regexp="\B!.*" --only-matching
    FCC> --no-filename EFEDriver2.f90. I was expecting an output equal
    FCC> to the efe2.f90 without all the comments. But I get nothing,
    FCC> only a comment saying that there were matches.

sed 's/!.*$//' foobar.f90 > foobar-sans-comments.f90



-- 
Lee Sau Dan                     李守敦(Big5)                    address@hidden(HZ) 

E-mail: address@hidden
Home page: http://www.informatik.uni-freiburg.de/~danlee


reply via email to

[Prev in Thread] Current Thread [Next in Thread]