[Za-pm] Script
Bartho Saaiman
bartho at cae.co.za
Wed Jun 4 07:46:13 CDT 2003
Hi Oskar.
Your assumption that the log lines are wrapped is correct. If I use my
previous bash script I get the same as with this perl script that you
suggest.
I need to filter this file in such a manner that it only displays the
email of the person that the mail originated from and obviously there
might be more than one email address. If I use
awk '{print $8, $9, $10}' it returns the values for column 8, 9 and 10
from the input file. What I want is to only have the emails
(user1 at domain.co.za, user2 at domain.co.za etc.) to be filtered to an
output file which I could use for accountting purposes.
Does this make more sense??
:)
Oskar Pearson wrote:
> On Wed, Jun 04, 2003 at 08:33:33AM +0200, Bartho Saaiman wrote:
>
> I'm not sure I understand the output you want, I'm afraid. I'm also
> assuming that the log lines above weren't meant to be wrapped? (ie
> they were one long line)
>
> how about something like this:
>
> oskar at core1:~$ cat t.txt
> [Fri May 23 11:02:12 SAST 2003] SMS user at domain.co.za sent 43 characters to 271234567891
> [Fri May 23 18:16:02 SAST 2003] SMS "Some User" <user at domain.co.za> sent 150 characters to 271234567891
> [Sat May 24 12:51:37 SAST 2003] SMS "Some User" <user at domain.co.za> sent 151 characters to 271234567891
> [Mon May 26 15:16:00 SAST 2003] SMS Some User <user at domain.co.za> sent 142 characters to 271234567891
> oskar at core1:~$ cat t.pl
> while (<STDIN>) {
> my ($date, $address, $characters, $cell) =
> $_ =~ /^\[(.+)\] SMS +(.+) sent (.+) characters to (.+)$/;
> print "$cell no, $characters chars (from $address at $date)\n";
> }
> oskar at core1:~$ perl t.pl < t.txt
> 271234567891 no, 43 chars (from user at domain.co.za at Fri May 23 11:02:12 SAST 2003)
> 271234567891 no, 150 chars (from "Some User" <user at domain.co.za> at Fri May 23 18:16:02 SAST 2003)
> 271234567891 no, 151 chars (from "Some User" <user at domain.co.za> at Sat May 24 12:51:37 SAST 2003)
> 271234567891 no, 142 chars (from Some User <user at domain.co.za> at Mon May 26 15:16:00 SAST 2003)
> oskar at core1:~$
> http://mail.pm.org/mailman/listinfo/za-pm
--
# Bartho Saaiman
# Stellenbosch Automotive Engineering
# Tel :: 27 21 882 8820 x 215
# Cell :: 27 82 551 2703
# Email :: bartho @ cae.co.za
# GnuPG Key is available at http://www.cae.co.za/people/bartho
More information about the Za-pm
mailing list