Subject: bug#12115: Please add tip about using tac to reverse a file byte-by-byte

From: Eric Blake <[email-masked]>
Date: Fri, 01 Feb 2013 15:04:22 -0700

On 02/01/2013 02:43 PM, Reuben Thomas wrote:
> On 1 February 2013 21:36, Paul Eggert <[email-masked]> wrote:
> 
>> On 02/01/13 11:14, Reuben Thomas wrote:
>>
>>> Given how long it took how many experts to come up with a valid
>>> incantation, it seems to me it *is* a useful documentation example.
>>
>> Sure, but the valid incantation is a bit confusing, and it's not
>> documented correctly (it reverses characters, not bytes).
>> As far as I know there's no portable way to use 'tac' to
>> reverse a file byte-by-byte.

Use LC_ALL=C to force single-byte characters.

>>
> 
> Thanks!
> 
> What about a way to do it on a GNU system? It seems reasonable to document
> GNU-specific hacks in GNU documentation when a portable solution is not
> forthcoming.

tac is a GNU program not standardized elsewhere, so if you have tac, it
is likely GNU tac to begin with.

The manual already contains:

@example
# Reverse a file character by character.
tac -r -s 'x\|[^x]'
@end example

Do we need a further example, or just modify that existing example to
call out the use of LC_ALL=C for reversing by bytes instead of characters?

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org