GNU bug report logs -
#13301
patch to preserve field order in cut
Previous Next
Reported by: Brad Cater <bradcater <at> gmail.com>
Date: Fri, 28 Dec 2012 23:27:02 UTC
Severity: normal
Tags: notabug
Merged with 6394,
9507
Done: Pádraig Brady <P <at> draigBrady.com>
Bug is archived. No further changes may be made.
Full log
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Hello
I found that
echo "a,b,c" | cut -d"," -f1,2
gives the same result as
echo "a,b,c" | cut -d"," -f2,1
This means that it's necessary to use another process to re-order columns.
I have written a patch for cut.c included in coreutils-8.20 (
http://ftp.gnu.org/gnu/coreutils/coreutils-8.20.tar.xz) that adds a -p
option to preserve field order. This means that doing
echo "a,b,c" | cut -d"," -f2,1
still gives
a,b
but
echo "a,b,c" | cut -d"," -f2,1 -p
gives
b,a
The current implementation of cut.c uses putchar so that a full line need
not be held in memory, whereas holding a full line is required to re-order
the fields rather than printing them from an input stream. This patch uses
putchar when -p is not used, but it buffers a full line when -p is used.
What should I do next? I would like to have someone more experienced than I
evaluate the changes so that I can improve them and add this functionality
to coreutils.
Thank you
-Brad
[Message part 2 (text/html, inline)]
[cut.8.20.preserve_field_order.patch (application/octet-stream, attachment)]
This bug report was last modified 12 years and 128 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.