I have a log file in which most lines are not interesting most of the
time. These line all contain a certain string. Is there a way to
display only those lines that do not contain a certain string?
On Wed, 18 May 2022 13:39:26 +0200, Cecil Westerhof <Cecil@decebal.nl>
wrote:
I have a log file in which most lines are not interesting most of the
time. These line all contain a certain string. Is there a way to
display only those lines that do not contain a certain string?
I use M-x delete-matching-lines but this changes the buffer, so be careful not to accidentally save...
I have a log file in which most lines are not interesting most of the
time. These line all contain a certain string. Is there a way to
display only those lines that do not contain a certain string?
Cecil Westerhof <Cecil@decebal.nl> writes:
I have a log file in which most lines are not interesting most of the
time. These line all contain a certain string. Is there a way to
display only those lines that do not contain a certain string?
I'd use grep (the Emacs command that runs grep) but using the -v
argument that show only non-matching lines.
But out of Emacs, I'd use
$ tail -f logfile | grep -v boring-string
since that "follows" the file, showing new lines as they appear. (When
I say "out of Emacs" you can, of course, run this in a Emacs shell
window.)
Ben <ben.usenet@bsb.me.uk> writes:
Cecil Westerhof <Cecil@decebal.nl> writes:
I have a log file in which most lines are not interesting most of the
time. These line all contain a certain string. Is there a way to
display only those lines that do not contain a certain string?
That would also be an option, but at the moment I chose the following function:
(defun dcbl-reduced-logfile (filter-string)
(interactive "s Filter String: ")
(message filter-string)
(let ((buffer-name (generate-new-buffer-name "reduced-logfile"))
(text (buffer-substring (point-min) (point-max))))
(switch-to-buffer buffer-name)
(insert text)
(beginning-of-buffer)
(delete-matching-lines filter-string)
))
Just whipped it up, so I am open for improvements.
(Should probably put name of current buffer in the new buffer name.)
| Sysop: | Amessyroom |
|---|---|
| Location: | Fayetteville, NC |
| Users: | 65 |
| Nodes: | 6 (0 / 6) |
| Uptime: | 02:38:44 |
| Calls: | 862 |
| Files: | 1,311 |
| D/L today: |
10 files (20,373K bytes) |
| Messages: | 264,324 |