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

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

Re: How to find lines not matching a certain pattern - ie grep -v


From: Dan Espen
Subject: Re: How to find lines not matching a certain pattern - ie grep -v
Date: Sun, 22 Feb 2015 15:40:33 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

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


reply via email to

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