How to mark all lines in a file containing pattern "aabbcc"?
Assume I have a very large (huge) text file with 100000 lines, Think of a log file.
I want to delete now all of the lines which contain a certain pattern simplified e.g. “aabbcc”.
How can I achieve this?
I miss a function/menu “display (only) all lines containing pattern”.
Then I could mark+delete them.
Can this option be added in the next release?
Open find and replace dialog, check “Regular expressions”. Replace:
Mark the lines with the Find mask, then on the menu: Search/Bookmark/Remove Bookmarked Lines.
@jonandr: be careful that the line ending could be a single linefeed: it’s better to put a question mark after the carriage return.
I don’t know exactly what aabbcc is meant to stand for - does ‘a’ stand for one character?
Anyway, you could do the search with a regular expression. Then you could create a macro out of a search followed by a line delete. After that, you could use the repeat macro button, and put in a large number.
Remember that macros can be saved and then executed like other commands.
The remark of ptonolio about the End of Line characters is quite judicious ! But we can avoid the
\r?\nsyntax, using the syntax
\R. This syntax matches ANY end of line (
\r\nin Windows files,
\nin Unix/OSX files and
\rin Old Mac files )
In addition, I would add the modifier
(?-s), at the beginning of the search regex ( meaning NOT a SINGLE line ), just in case, you checked, by mistake, the . matches new line option, in the Replace dialog.
To end, if you mind about the case, I would add the modifier
(?-i)( meaning NO IGNORE case ), just in case you forgot to check the Match case option
So, according that you would like to delete any line, containing, exactly, the literal string aabbcc, choose the regular expression search mode, with :
REPLACE : Nothing
and click on the Replace All button