procmail
[Top] [All Lists]

RE: Question about simple sorting.

2005-08-27 01:11:55

Gary wrote:
Good idea, but I think the 'tr' invocation should be:
   tr -d '[\n\r]' | tr -s '[[:space:]]' ' '

Michelle chastined:
No, it was a suggestion on this list and it works perfectly.

Your original suggestion stated:

SUB=`formail -zX Subject: |mimedecode |tr -ds '[ntr]' ' '`

Consider the following example:

% echo 'AtrainZ' | tr -ds '[rtn]' ' '

This prints the following:

AaiZ

It turns out that -d and -s don't work well together because
once the character is deleted, it can't be checked for
multiple suppression and translation.  Let's drop the -d
and try again:

% echo 'AtrainZ' | tr -s '[rtn]' ' ' 
A ai Z

Now lets add one tab (using control-v <tab>) after A and two
before the Z, and try a substitution set where the
short hand name for tab uses the \t form.

% echo 'A  train           Z' | tr -s '[\t]' ' '
A train Z

We can throw \r and \n into that set, but the trailing newline
will become a space:

% echo 'A  train           Z' | tr -s '[\t\r\n]' ' '
A train Z %

The trailing % above indicates simply that the newline
was replaced with a space.

This is using version 5.2.1 of the GNU implementation of 'tr'.

____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail