[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: tac --separator
From: |
Bob Proulx |
Subject: |
Re: tac --separator |
Date: |
Mon, 4 Feb 2008 11:26:42 -0700 |
User-agent: |
Mutt/1.5.13 (2006-08-11) |
John Cowan wrote:
> Bob Proulx scripsit:
> > 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.
Ah, yes, you are right of course. That is a much better description.
Thanks for the correction!
> > 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.
Hmm... It is not irrelevant. Look at this case then:
printf "a b c d" | tac --separator=" "; echo
dc b a
Because there is no terminator for the d record it is output without
one when passed through tac. I think a delimiter really is needed
after the d record on input for good results on output.
Bob