From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: FCC Newsgroups: gmane.emacs.help Subject: grep can help? Date: Wed, 21 Apr 2004 16:01:08 +0200 Organization: Universitat Politecnica de Catalunya Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1082559383 21888 80.91.224.253 (21 Apr 2004 14:56:23 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 21 Apr 2004 14:56:23 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Apr 21 16:56:16 2004 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1BGJ96-0006cQ-00 for ; Wed, 21 Apr 2004 16:56:16 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.30) id 1BGIWq-0003HA-Lo for geh-help-gnu-emacs@m.gmane.org; Wed, 21 Apr 2004 10:16:44 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!newsmi-us.news.garr.it!newsmi-eu.news.garr.it!NewsITBone-GARR!irazu.switch.ch!switch.ch!news.rediris.es!news.cesca.es!news.upc.es!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 29 Original-NNTP-Posting-Host: adca05.upc.es Original-X-Trace: defalla.upc.es 1082556211 6117 147.83.51.18 (21 Apr 2004 14:03:31 GMT) Original-X-Complaints-To: newsmngr@upc.es Original-NNTP-Posting-Date: 21 Apr 2004 14:03:31 GMT User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax) X-Accept-Language: en-us, en, es-es, tr Original-Xref: shelby.stanford.edu gnu.emacs.help:122530 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.4 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:17818 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:17818 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