unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* grep can help?
@ 2004-04-21 14:01 FCC
  2004-04-21 15:09 ` Glenn Morris
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: FCC @ 2004-04-21 14:01 UTC (permalink / raw)


Hello all,

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

Initially I was trying to use isearch for a regexp but only to search 
for those occurences which are not in comments (or which do not appear 
after the character !). After spending some time with Google, it turned 
out that this is not possible because one cannot "invert a match", which 
is what is required here.

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

Any idea how I can do that?

Thanks,

FCC

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2004-04-22 15:51 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-04-21 14:01 grep can help? FCC
2004-04-21 15:09 ` Glenn Morris
2004-04-21 16:33   ` FCC
2004-04-21 16:52 ` LEE Sau Dan
2004-04-21 17:59 ` FCC
2004-04-22 10:27   ` Albert Reiner
2004-04-22 11:23     ` FCC
2004-04-22 14:14       ` Barry Margolin
2004-04-22 15:51 ` Johan Bockgård

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).