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

Previous Next

Package: coreutils;

Reported by: Reuben Thomas <rrt <at> sc3d.org>

Date: Wed, 1 Aug 2012 21:46:01 UTC

Severity: normal

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Jim Meyering <jim <at> meyering.net>
To: Reuben Thomas <rrt <at> sc3d.org>
Cc: 12115 <at> debbugs.gnu.org
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:
> +
> +@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}




This bug report was last modified 12 years and 114 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.