Skip to content

Instantly share code, notes, and snippets.

@arossouw
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arossouw/2adb82ad208295be31a2 to your computer and use it in GitHub Desktop.
Save arossouw/2adb82ad208295be31a2 to your computer and use it in GitHub Desktop.
(require '[clojure.java.io :as io])
(use '[clojure.string :only (join)])
;; logfile contains:
;; login: [10.0.3.162] user1@domain.co.za plaintext User logged in
(def re-email #"\s+\'([a-z\.\-0-9]+?\@[a-z\.\_\-0-9]+)\'$")
(def re-imap-login #"login\:\s\[[0-9\.]+\]\s([a-z\.\-0-9]+?\@[a-z\.\_\-0-9]+)")
(defn lines-re [file]
(keep #(last (re-find re-imap-login %)) (line-seq (io/reader file))))
(spit "/tmp/test.txt" (join "\n" (lines-re "/home/arno/imapd.log")))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment