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: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#12115: closed (Please add tip about using tac to reverse a
 file byte-by-byte)
Date: Fri, 01 Feb 2013 21:37:03 +0000
[Message part 1 (text/plain, inline)]
Your message dated Fri, 01 Feb 2013 13:36:00 -0800
with message-id <510C3540.2010806 <at> cs.ucla.edu>
and subject line Re: bug#12115: Please add tip about using tac to reverse a file byte-by-byte
has caused the debbugs.gnu.org bug report #12115,
regarding Please add tip about using tac to reverse a file byte-by-byte
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
12115: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=12115
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Reuben Thomas <rrt <at> sc3d.org>
To: bug-coreutils <bug-coreutils <at> gnu.org>
Subject: Please add tip about using tac to reverse a file byte-by-byte
Date: Wed, 1 Aug 2012 22:37:42 +0100
Patch:

From 3c1b7d442dc6161e3c88703c9acc3f768f9ba689 Mon Sep 17 00:00:00 2001
From: Reuben Thomas <rrt <at> sc3d.org>
Date: Wed, 1 Aug 2012 22:35:38 +0100
Subject: [PATCH] doc: Add tip on reversing a file byte-by-byte

* doc/coreutils.texi: Note how to use tac to reverse a file
byte-by-byte.
---
 doc/coreutils.texi |    6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index 516ec73..66b0838 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -1625,6 +1625,12 @@ Use @var{separator} as the record separator,
instead of newline.

 @end table

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


-- 
1.7.9.5



-- 
http://rrt.sc3d.org


[Message part 3 (message/rfc822, inline)]
From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Reuben Thomas <rrt <at> sc3d.org>
Cc: 12115-done <at> debbugs.gnu.org
Subject: Re: bug#12115: Please add tip about using tac to reverse a file
	byte-by-byte
Date: Fri, 01 Feb 2013 13:36:00 -0800
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.

I installed this:


From dad0a3c743464664ed6a7ae8445cb58b8326db6d Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert <at> cs.ucla.edu>
Date: Fri, 1 Feb 2013 13:32:48 -0800
Subject: [PATCH] doc: say how to tac char-by-char

This fixes Bug#12115, reported by Reuben Thomas.
* doc/coreutils.texi (tac invocation): Document how to reverse a
file character by character.  Break out MS-DOS into a separate
section, like 'cat' does.
---
 doc/coreutils.texi | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index eac8d52..e29af8b 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -1613,10 +1613,7 @@ precedes in the file.
 @itemx --regex
 @opindex -r
 @opindex --regex
-Treat the separator string as a regular expression.  Users of @command{tac}
-on MS-DOS/MS-Windows should note that, since @command{tac} reads files in
-binary mode, each line of a text file might end with a CR/LF pair
-instead of the Unix-style LF.
+Treat the separator string as a regular expression.
 
 @item -s @var{separator}
 @itemx --separator=@var{separator}
@@ -1626,8 +1623,18 @@ Use @var{separator} as the record separator, instead of newline.
 
 @end table
 
+On systems like MS-DOS that distinguish between text and binary files,
+@command{tac} reads and writes in binary mode.
+
 @exitstatus
 
+Example:
+
+@example
+# Reverse a file character by character.
+tac -r -s 'x\|[^x]'
+@end example
+
 
 @node nl invocation
 @section @command{nl}: Number lines and write files
-- 
1.7.11.7




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.