Skip to content

Instantly share code, notes, and snippets.

@ishideo
Created October 16, 2017 05:38
Show Gist options
  • Save ishideo/4e9a0f21840f0dd5ed81ed38e7af4908 to your computer and use it in GitHub Desktop.
Save ishideo/4e9a0f21840f0dd5ed81ed38e7af4908 to your computer and use it in GitHub Desktop.
;; -*- coding: utf-8; lexical-binding: t -*-
;; emacs -Q --script remove-match-lines-single.el log.txt '^\n.*\n'
(defun remove-match-lines (file regex)
(with-current-buffer (find-file-noselect file)
(goto-char (point-min))
(while (re-search-forward regex nil t)
(replace-match ""))
(save-buffer)))
(defun replace-escape-new-line (str)
(replace-regexp-in-string "\\\\n" "\n" str))
(let ((file (car argv))
(regex (replace-escape-new-line (nth 1 argv))))
(remove-match-lines file regex))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment