From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dan Espen Newsgroups: gmane.emacs.help Subject: Re: How to find lines not matching a certain pattern - ie grep -v Date: Sun, 22 Feb 2015 15:40:33 -0500 Organization: A noiseless patient Spider Message-ID: References: <6a41f4ac-f7e7-49f1-a593-501d82d4c733@googlegroups.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1424637934 20790 80.91.229.3 (22 Feb 2015 20:45:34 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 22 Feb 2015 20:45:34 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Feb 22 21:45:19 2015 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YPdOx-0008N0-6g for geh-help-gnu-emacs@m.gmane.org; Sun, 22 Feb 2015 21:45:19 +0100 Original-Received: from localhost ([::1]:41196 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YPdOw-0005Gw-F9 for geh-help-gnu-emacs@m.gmane.org; Sun, 22 Feb 2015 15:45:18 -0500 Original-Path: usenet.stanford.edu!goblin1!goblin.stu.neva.ru!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 37 Injection-Info: mx02.eternal-september.org; posting-host="ad871ce417d1fb2ea3c87e49e48c0ae1"; logging-data="31064"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19q1jb6ikiSP8PmydiB5JbJWZV40zO6QT0=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:h5XlTRinE4oZ0W884mkinXo4Uis= Original-Xref: usenet.stanford.edu gnu.emacs.help:210555 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 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 Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:102832 Archived-At: gnuist006@gmail.com writes: > Hi All, > > Once in a while I have to do something to lines that do not have a > certain string or set of strings in them. I know how to find lines > with a string. I also know how to find lines with a set of strings, ie > by using the regexp > > string1\|string2\| .... > > But I dont know how to find strings that do not have the string or strings. > > For the moment, I have been doing this in bash using grep -v. I assume > that this is also doable in awk and possibly sed. But I dont know how > to do this in a direct manner in emacs. > > One indirect method in emacs would be to search for the lines with the > strings and label/mark them with # in the beginning. > > Next, label/mark all the lines with @ in the beginning. > > Next, replace all the @#'s in the beginning with # or even nothing, ie "" > > Now, you can search for all the lines with @ in the beginning and do whatever to them. > > > I assume that this is such a common operation that there would be > something cleaner and better for this in emacs already. M-x grep then enter the string followed by -v then the filename pattern. -- Dan Espen