Author Topic: [Bash] Mailgrep via /var/log/mail.log  (Read 1302 times)

p

  • Global Moderator
  • Apache
  • *****
  • Posts: 110
  • Karma: +27/-0
    • View Profile
[Bash] Mailgrep via /var/log/mail.log
« on: December 13, 2013, 11:06:43 am »
Code: [Select]
#!/bin/bash

if [ $# -ne 2  ]
then
    echo "Usage: $0 name@from.xy name@to.xy"
else
    for i in $(cat /var/log/mail.log | grep -i $1 | grep from | awk '{ print $6 }');
    do
        cat /var/log/mail.log | grep $i | grep -i $2 | grep to
    done
fi


Edit:
Will noch flags für -to, -from und -log hinzufügen - hatte aber keine Lust mehr. Hatte erstmal den Zweck erfüllt. ;)
« Last Edit: December 13, 2013, 02:49:51 pm by p »