Last active
August 29, 2015 14:14
-
-
Save arossouw/2adb82ad208295be31a2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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