bug-coreutils
[Top][All Lists]
Advanced

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

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


From: Jim Meyering
Subject: bug#12115: Please add tip about using tac to reverse a file byte-by-byte
Date: Thu, 02 Aug 2012 09:22:55 +0200

Reuben Thomas wrote:
...
> +To reverse a file byte by byte, use:
> +
> address@hidden
> +tac -r -s '.\| ' @var{file}
> address@hidden 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}





reply via email to

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