bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: tac --separator


From: John Cowan
Subject: Re: tac --separator
Date: Mon, 4 Feb 2008 12:51:14 -0500
User-agent: Mutt/1.5.13 (2006-08-11)

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    address@hidden
Economists were put on this planet to make astrologers look good.
        --Leo McGarry




reply via email to

[Prev in Thread] Current Thread [Next in Thread]