Bob Proulx scripsit:
> Erkan Yanar wrote:
> > $ echo -e "a b c d"| tac  --separator=" " 
> > d
> > c b a
> > 
> > Why is tac only using the first space as separator?
> 
> It is using all of the spaces.  See that "c b a" is reversed.  But the
> problem is that the "d" is not terminated.

I don't think your explanation really explains.  With the terminator set
to space, the four records in the file are "a", "b", "c", and "d\n",
where the newline is added by "echo".  So on output, you get a "d\n",
a "c", a "b", and an "a", all separated by spaces.

> Try this to add a space terminator:
> 
>   printf "a b c d " | tac --separator=" " ; echo
>   d c b a 
> 
>   printf "a b c d " | tac --separator=" " | od -c -tx1
>   0000000   d       c       b       a    
>           64 20 63 20 62 20 61 20

This is different because "printf" doesn't add a newline to the end,
unlike "echo".  Having or not having a terminating space is irrelevant,
just as it's normally irrelevant whether you have a terminating newline.

-- 
John Cowan    http://ccil.org/~cowan    [EMAIL PROTECTED]
Economists were put on this planet to make astrologers look good.
        --Leo McGarry


_______________________________________________
Bug-coreutils mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-coreutils

Reply via email to