procmail
[Top] [All Lists]

Re: newline

2002-06-05 20:49:19
On Wed, Jun 05, 2002 at 01:05:00PM +0300, Udi Mottelo wrote:

      I wander, I checked it on Solaris7 (awk, nawk) and RedHat7.2
      please, try in you system:

yarkon~% echo -n "hello:" | awk -F":" '{print $1; print NF}'
hello
2
yarkon~%

      Is ":" a Field Separator or Record Separator? (notice the "-n")
      Maybe the gnu has different answer.

      However, for procmail usage I belive that tr(1) or cut(1) are
      much more efficient and elegant.


Udi,

   I must agree that the solutions, using tr and cut, are both more
efficient and elegant than the more complex solutions. 

   In examining your alternative ways to help procmail clobber ^Ms at
line ends, however, we need to be sure that the test input actually has
them. 

   echo -n only suppresses the newline (== linefeed == 0a).  To
synthesise input with a carriage return (== 0d), I saved a text sample
from Vim, after a ":set fileformat=dos". It would be very strange if any
common unix utility produced these ^Ms, and you might like to compare:

echo -n "hello:" | od -x
0000000 6568 6c6c 3a6f
0000006

with:

echo -n "hello:^M" | od -x
0000000 6568 6c6c 3a6f 000d
0000007

In your example there is no 0d (^M) to remove, so any filter appears
to work.

   In case the relevant part of the ascii table is fuzzy, from
"man ascii":

Oct   Dec   Hex   Char
----------------------
012   10    0A    LF  '\n'
015   13    0D    CR  '\r'


   Regarding awk fields and records:

   -F sets the separator between fields on a line.
   RS sets the separator between records. (lines)
   (This is not the forum for going into multi-line records. :-)

   Hope that helps.

Regards,
Erik


_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>