ishideo
10/16/2017 - 5:39 AM

remove-match-lines-multiple.el

;; -*- 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))