From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: gnuist006@gmail.com Newsgroups: gmane.emacs.help Subject: How to find lines not matching a certain pattern - ie grep -v Date: Sun, 22 Feb 2015 10:11:40 -0800 (PST) Message-ID: <6a41f4ac-f7e7-49f1-a593-501d82d4c733@googlegroups.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: ger.gmane.org 1424628919 13927 80.91.229.3 (22 Feb 2015 18:15:19 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 22 Feb 2015 18:15:19 +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 19:15: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 1YPb3m-0005WH-OX for geh-help-gnu-emacs@m.gmane.org; Sun, 22 Feb 2015 19:15:18 +0100 Original-Received: from localhost ([::1]:40848 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YPb3l-0003hs-V1 for geh-help-gnu-emacs@m.gmane.org; Sun, 22 Feb 2015 13:15:17 -0500 X-Received: by 10.182.78.69 with SMTP id z5mr8219737obw.4.1424628700995; Sun, 22 Feb 2015 10:11:40 -0800 (PST) X-Received: by 10.182.66.107 with SMTP id e11mr35240obt.13.1424628700822; Sun, 22 Feb 2015 10:11:40 -0800 (PST) Original-Path: usenet.stanford.edu!hl2no23421229igb.0!news-out.google.com!db6ni33843igc.0!nntp.google.com!hl2no23421224igb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=99.103.153.82; posting-account=REkl4woAAABFXaU7nL79XtGpnmNCQ415 Original-NNTP-Posting-Host: 99.103.153.82 User-Agent: G2/1.0 Injection-Date: Sun, 22 Feb 2015 18:11:40 +0000 Original-Xref: usenet.stanford.edu gnu.emacs.help:210554 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:102831 Archived-At: 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. Cheers Bolega