[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
How to find lines not matching a certain pattern - ie grep -v
From: |
gnuist006 |
Subject: |
How to find lines not matching a certain pattern - ie grep -v |
Date: |
Sun, 22 Feb 2015 10:11:40 -0800 (PST) |
User-agent: |
G2/1.0 |
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
- How to find lines not matching a certain pattern - ie grep -v,
gnuist006 <=