Skip to content

Instantly share code, notes, and snippets.

@ishideo
Last active November 1, 2017 12:56
Show Gist options
  • Save ishideo/19b06e828268d1be3982cf174b9c3432 to your computer and use it in GitHub Desktop.
Save ishideo/19b06e828268d1be3982cf174b9c3432 to your computer and use it in GitHub Desktop.
;; -*- coding: utf-8; lexical-binding: t -*-
;; emacs -Q --script remove-match-lines-multiple.el log.txt
(defun remove-match-lines (file patterns)
(with-current-buffer
(find-file-noselect file)
(mapcar
(lambda (x)
(goto-char (point-min))
(while (re-search-forward x nil t)
(replace-match ""))
(save-buffer))
patterns)))
(let ((file (car argv))
(patterns (list "^\n.*\n" "abc")))
(remove-match-lines file patterns))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment