From owner-freebsd-questions@FreeBSD.ORG Mon Jun 15 00:32:58 2015 Return-Path: Delivered-To: freebsd-questions@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 4FDA57A7 for ; Mon, 15 Jun 2015 00:32:58 +0000 (UTC) (envelope-from patrickhess@gmx.net) Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mout.gmx.net", Issuer "TeleSec ServerPass DE-1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D224E1B9 for ; Mon, 15 Jun 2015 00:32:57 +0000 (UTC) (envelope-from patrickhess@gmx.net) Received: from desk8.phess.net ([95.88.11.237]) by mail.gmx.com (mrgmx001) with ESMTPSA (Nemesis) id 0LfkUs-1ZNgY71ZXu-00pNgl for ; Mon, 15 Jun 2015 02:27:37 +0200 From: Patrick Hess To: freebsd-questions@freebsd.org Subject: Re: Script question Date: Mon, 15 Jun 2015 02:27:35 +0200 Message-ID: <2609852.Pc7nSdcYla@desk8.phess.net> User-Agent: KMail/4.14.2 (FreeBSD/10.1-RELEASE; KDE/4.14.2; i386; ; ) In-Reply-To: <20150615015516.b3ea7633.freebsd@edvax.de> References: <20150615015516.b3ea7633.freebsd@edvax.de> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Provags-ID: V03:K0:YX280UFJQlLyqcH93PJmX0P1FWSvRIcU7Gsf3Sr9tYDVD17iugx cFwE/F7SHWSfXjVG+ZjRmn8C2laEHTB+oyUV4v9cUyvay0kps16SUEbjmdzDpmEm4TjRrf1 ERW00Mi6kBMYJOgkRR+MiisacnMVIKK8TUNAeRj5zm05hXFQ+xxAD8yJl4yFpanzynbMj4F EI9GmpWfAT6BGOuGntlTw== X-UI-Out-Filterresults: notjunk:1;V01:K0:iRuz6cC7L1M=:d6EtE8WajHsrPImiQ/cezB GgqMveuHshu60f5rgI2dEo5P+zFVgs+4kE5yb8MCOlDHVfIc3p/Gfa4ShXFaNwC4BZn4kk63a yPyddiL8+zHnbVgFyDLTQrCAk5mgLCNcs17vEN0USJpuuZxUnXy4dBrKZvjEv2+mM1amgGXVo wPfryw3TEy/Eaj+pANfjv085gGd9JaoC0Dm32H9r5cQ/zpzbjln5i9B/5npF2oFCbT1jAp3SL ym7nFDvM3wByqI+jC93GPlOn53nsIyAcEImTEkAO6k8QmDzhVYJkqZ8sPbtIf/Tq/R5VkguKE KDj0gPWZmIbsTkua7WCQjol980wGwTaFKBuXO63AenyJVtbeEd2Ql15IK+FzWXh83XVxARj4M GEXJnHPL0Zb97FCA3PToAiBLBWdz259K2+XMXxFgIbw5wLVmWGJAWDdjzhqF+ky41eJAV4BDu R9FMTxEHBIujbHhcbn0dRz7a+CL0JsmL7jufpBNEt4Uk1bNEM7fM75qHOfFp3BpaWSmyqjuQK RHpsHB0GgyX1Q1Wgc78DjdxnTB/uvv+RzLFwiG6ojmyHZcBkWLx90F7k5Kb0mnKMhM+wEo+74 Ug7wER2q4HK+1ihE4NcM4oy6qM+hVHb5yVk/YsgxC0y4rHCZfe35kyR6gyh4MOkXWcXGDrb04 ZCoFUP7nytHGKc9KGfVpnQYKy9d62G11Hxp462xDHKGGFe3wj/ODZ7HL4ZUjxbb5BrcY= X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Jun 2015 00:32:58 -0000 Polytropon wrote: > Or if you want to omit the grep call: > > awk '/spam=YES/ {print $11}' /var/log/maillog | sort | uniq | sed -e 's/^.*=//' > /tmp/spam-ip.txt > > And then continue: > > cat /tmp/spam-ip.txt >> /usr/samba/mail/envelope > cat /tmp/spam-ip.txt | mail -s "SPAM IPs...." us.navy@outlook.com > > Finally, you can easily remove /tmp/spam-ip.txt. You could even take this one step further and eliminate the need for a temporary file altogether by making use of tee(1): awk '/spam=YES/ {print $11}' /var/log/maillog | sort | uniq | sed -e 's/^.*=//' | tee -a /usr/samba/mail/envelope | mail -s "SPAM IPs...." us.navy@outlook.com Patrick