Re: Was "re: Alternatives to entourage and mail" now "in english please :-)"

2003-06-24 Thread Onno Benschop
While this may look really scary:
grep "X-Mailer" mbox | sort | uniq -c | sort -n -r

It really isn't.

You can entirely ignore this message if you like, but you might just
like this method of doing things - which I confess I much prefer to more
manual methods suggested by Shay.

While I typed the command into a Linux console, the principle is the
same for MacOS X. (The options may be slightly different, but I don't
have an OS X box handy right now.) If I use the word unix below, I mean
any flavour of unix, so MacOS X, Linux, Solaris - whatever.

When a program runs, it generally requires some input and generally
creates some output. Under unix you can string together a number of
commands using a pipe which is denoted by the "|". Instead of saving the
output that comes from a command to a file, then processing that file
with the next command, you can directly send the output as input to the
next command.

So, let's break this down:

grep "X-Mailer" mbox

The "grep" command looks for a string in a file. So here we look for the
string "X-Mailer" in the file mbox. If you had a file mbox and it
contained the string "X-Mailer" on any of its lines, the output would
include only those lines that matched.

So, we'd get something like:

X-Mailer: Microsoft Outlook Express Macintosh Edition - 4.5 (0410)
X-Mailer: Apple Mail (2.551)
X-Mailer: Yahoo Groups Message Poster
X-Mailer: Apple Mail (2.552)
X-Mailer: Microsoft Outlook Express Macintosh Edition - 4.5 (0410)
X-Mailer: QUALCOMM Windows Eudora Version 4.3.2
X-Mailer: Apple Mail (2.552)
X-Mailer: Microsoft Outlook Express Macintosh Edition - 4.5 (0410)
X-Mailer: Mozilla 4.7 (Macintosh; I; PPC)
X-Mailer: eGroups Message Poster

So, "grep" created a list of lines that had "X-Mailer" in them.

The next step is to sort these lines alphabetically using the "sort"
command, which results in:

X-Mailer: Apple Mail (2.551)
X-Mailer: Apple Mail (2.552)
X-Mailer: Apple Mail (2.552)
X-Mailer: eGroups Message Poster
X-Mailer: Microsoft Outlook Express Macintosh Edition - 4.5 (0410)
X-Mailer: Microsoft Outlook Express Macintosh Edition - 4.5 (0410)
X-Mailer: Microsoft Outlook Express Macintosh Edition - 4.5 (0410)
X-Mailer: Mozilla 4.7 (Macintosh; I; PPC)
X-Mailer: QUALCOMM Windows Eudora Version 4.3.2
X-Mailer: Yahoo Groups Message Poster

The next step is to make each entry unique, so each email program only
appears once. The "uniq" command can not only make each line unique, but
it also has the ability to count the number of occurrences using the
'-c' option, so:

uniq -c

Results in:

1   X-Mailer: Apple Mail (2.551)
2   X-Mailer: Apple Mail (2.552)
1   X-Mailer: eGroups Message Poster
3   X-Mailer: Microsoft Outlook Express Macintosh Edition - 4.5 (0410)
1   X-Mailer: Mozilla 4.7 (Macintosh; I; PPC)
1   X-Mailer: QUALCOMM Windows Eudora Version 4.3.2
1   X-Mailer: Yahoo Groups Message Poster

While this list contains all of the information we wanted, it's not in
any order that allows us easily to determine which is the most used
mailer. 

The "sort" command called with no options sorts a list alphabetically.
If you give it '-n', it sorts numerically. '-r' makes the sorted list
reversed. So:

sort -n -r

Results in:

3   X-Mailer: Microsoft Outlook Express Macintosh Edition - 4.5 (0410)
2   X-Mailer: Apple Mail (2.552)
1   X-Mailer: Yahoo Groups Message Poster
1   X-Mailer: QUALCOMM Windows Eudora Version 4.3.2
1   X-Mailer: Mozilla 4.7 (Macintosh; I; PPC)
1   X-Mailer: eGroups Message Poster
1   X-Mailer: Apple Mail (2.551)

Which is the list that shay supplied us with. (I'll leave it as an
excercise to the reader to learn about the "cut" command to remove the
string "X-Mailer: " from the output :-)

How did I know what to do to get all this to work? Under unix you can
use the "man" command to find out what options each program uses. If you
use the "apropos" command, you can find out which commands might be
appropriate to actually do a task.

So, you can do:
man sort
man uniq
man grep

And:
apropos duplicate
apropos sort

Any more questions? Send them on down and I'll see what I can do...

PS, was this "English" enough?

Onno Benschop 

Connected via Optus B3 from S33:37'33" - E115:07'30" (Dunsborough, WA)
-- 
()/)/)() ..ASCII for Onno.. 
|>>? ..EBCDIC for Onno.. 
--- -. -. --- ..Morse for Onno.. 

Proudly supported by Skipper Trucks, Highway1, Concept AV, Sony Central, Dalcon
ITmaze - ABN: 56 178 057 063 - ph: 04 1219  - [EMAIL PROTECTED]



Re: Was "re: Alternatives to entourage and mail" now "in english please :-)"

2003-06-24 Thread Shay Telfer

If normal mortals would care to read the below, the reason some of us may
not use the list in the way others would like us to is readily apparent :-)

 What I'd be interested in knowing is - how'd you create that list?


I am guessing a quick perl script run over a Eudora mailbox...


No need for perl:

grep "X-Mailer" mbox | sort | uniq -c | sort -n -r


No need for that, I have BBEdit (oh, ok, I did use uniq :)


I have no idea what it is all about. I use Mac OS since I prefer it to
Windows OS, (I like to be different) and I have a reasonable understanding
of them, but no more so than the average Mac user ... Or so I thought. I now
see that I am way down the evolutionary scale when it comes to understanding
them. I now what they do, and I know how to make them do what I want to do
once someone has done all the hard work and given me a nice piece of
software to use.


Basically I did

* Open BBEdit
* "Find" for "X-Mailer:" in multiple files pointed at my WAMUG 
mailbox folder' (all options in BBEdit's Find dialog)

* Wait for the results
* Copy the results out of the find window and paste them into a blank 
BBEdit document

* Use BBEdit's 'Sort' tool to sort the document
* Run the Unix program uniq over the document (with the -c option, 
for counting) to count occurrences of each line


Nothing too mystical, and more understandable to the layperson than 
the unix arcanery, albeit essentially the same process :)


Have fun,
Shay

--
=== Shay Telfer 
Perth, Western Australia Technomancer Join Team Sungroper, race the
Opinions for hire [POQ] 2003 World Solar Challenge
[EMAIL PROTECTED] fnord 



Was "re: Alternatives to entourage and mail" now "in english please :-)"

2003-06-24 Thread Angus Russell
If normal mortals would care to read the below, the reason some of us may
not use the list in the way others would like us to is readily apparent :-)

 What I'd be interested in knowing is - how'd you create that list?
>>> 
>>> I am guessing a quick perl script run over a Eudora mailbox...
>> 
>> No need for perl:
>> 
>> grep "X-Mailer" mbox | sort | uniq -c | sort -n -r
> 
> No need for that, I have BBEdit (oh, ok, I did use uniq :)

I have no idea what it is all about. I use Mac OS since I prefer it to
Windows OS, (I like to be different) and I have a reasonable understanding
of them, but no more so than the average Mac user ... Or so I thought. I now
see that I am way down the evolutionary scale when it comes to understanding
them. I now what they do, and I know how to make them do what I want to do
once someone has done all the hard work and given me a nice piece of
software to use.

I also wondered how Shay sorted out who used what (in apparently record
time) and am still wondering how he did it. However the important thing is
that he did, and it maybe sheds light on numerous issues ( I for one will be
looking into Mozilla)

Cheers

Angus