[Za-pm] Script
Bartho Saaiman
bartho at cae.co.za
Wed Jun 4 01:33:33 CDT 2003
I want to filter a log file that I currently have to manipulate
manually. So I was thinking to myself that this would be nice if I could
do this with Perl. If it would be easier in bash, suggestions would also
be welcome. So here is the scenario:
Output of log file (sms.log):
<snip>
[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
</snip>
So the first problem is that the user (Some User) detail is logged in
three different ways. I am also only interested in the email addres as I
can use this to do accountting with. I am currentl using bash like this:
[bartho at hercules bartho]$ cat smslog |grep "May"| grep "2003" |awk \
'{print $8, $9, $10}'
user at domain.co.za sent 47
"Some User" <user at domain.co.za>
Some User <user at domain.co.za>
Now this is where my problem starts. I probably need to use regular
expressions to feed it the month and the domain. The year I could
probably use in a regex too, but this doesn't change to often. Then I
ned to send this to a clean file only containing the emails that this
originated from. I do not need to sort them as unique since I have to
add them up, similar to 'wc -l'
I know this is a lot of questions, but any pointers would be appreciated.
--
# 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