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

From: Jim Meyering <[email-masked]>
Date: Thu, 02 Aug 2012 09:22:55 +0200

Reuben Thomas wrote:
...
> +To reverse a file byte by byte, use:
> +
> +@example
> +tac -r -s '.\| ' @var{file}
> +@end example
> +

Thanks!

That's a good demonstration.
Please note that it's not efficient and include the perl one-liner
for reference.

Here's a portable way to include the newline correction Eric mentioned:

nl='
'
tac -r -s ".\\|$nl" @var{file}

I would add that with a shell like bash or zsh you can do it more cleanly,
using $'\n' in place of the shell variable:
(note that below there's the added advantage of not having to
double-quote to include $nl and hence not having to double-backslash)

tac -r -s '.\|'$'\n' @var{file}