GNU bug report logs - #6394
Is it possible to reorder fields with cut?

Previous Next

Package: coreutils;

Reported by: Peng Yu <pengyu.ut <at> gmail.com>

Date: Thu, 10 Jun 2010 16:59:02 UTC

Severity: normal

Tags: notabug

Merged with 9507, 13301

Done: Pádraig Brady <P <at> draigBrady.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 6394 in the body.
You can then email your comments to 6394 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org:
bug#6394; Package coreutils. (Thu, 10 Jun 2010 16:59:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Peng Yu <pengyu.ut <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Thu, 10 Jun 2010 16:59:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Peng Yu <pengyu.ut <at> gmail.com>
To: bug-coreutils <at> gnu.org
Subject: Is it possible to reorder fields with cut?
Date: Thu, 10 Jun 2010 11:58:00 -0500
Hi,

I need to reorder the fields in a file. But the -f option can not be
used to reorder field 1 and field 2.

Basically, I want the original 1st field as the new 2nd field and the
original 2nd field the first. Is reordering fields possible with cut.

$ cat input.txt
a	b	c
e	f	g
$ cut -f 1,2 input.txt
a	b
e	f
$ cut -f 2,1 input.txt
a	b
e	f


-- 
Regards,
Peng




Information forwarded to owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org:
bug#6394; Package coreutils. (Thu, 10 Jun 2010 17:46:02 GMT) Full text and rfc822 format available.

Message #8 received at 6394 <at> debbugs.gnu.org (full text, mbox):

From: Eric Blake <eblake <at> redhat.com>
To: Peng Yu <pengyu.ut <at> gmail.com>
Cc: 6394 <at> debbugs.gnu.org
Subject: Re: bug#6394: Is it possible to reorder fields with cut?
Date: Thu, 10 Jun 2010 11:44:29 -0600
[Message part 1 (text/plain, inline)]
On 06/10/2010 10:58 AM, Peng Yu wrote:
> Hi,
> 
> I need to reorder the fields in a file. But the -f option can not be
> used to reorder field 1 and field 2.

Correct.  POSIX standardized this behavior because some scripts rely on
it, even though it may not be the most intuitive.

> 
> Basically, I want the original 1st field as the new 2nd field and the
> original 2nd field the first. Is reordering fields possible with cut.

No.  Use awk instead.

-- 
Eric Blake   eblake <at> redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

[signature.asc (application/pgp-signature, attachment)]

Added tag(s) notabug. Request was from Pádraig Brady <P <at> draigBrady.com> to control <at> debbugs.gnu.org. (Wed, 14 Jul 2010 16:32:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to Peng Yu <pengyu.ut <at> gmail.com> Request was from Pádraig Brady <P <at> draigBrady.com> to control <at> debbugs.gnu.org. (Wed, 14 Jul 2010 16:32:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 12 Aug 2010 11:24:04 GMT) Full text and rfc822 format available.

bug unarchived. Request was from Eric Blake <eblake <at> redhat.com> to control <at> debbugs.gnu.org. (Tue, 20 Sep 2011 18:03:01 GMT) Full text and rfc822 format available.

Forcibly Merged 6394 9507. Request was from Eric Blake <eblake <at> redhat.com> to control <at> debbugs.gnu.org. (Tue, 20 Sep 2011 18:03:01 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 19 Oct 2011 11:24:03 GMT) Full text and rfc822 format available.

bug unarchived. Request was from Pádraig Brady <P <at> draigBrady.com> to control <at> debbugs.gnu.org. (Mon, 14 Jan 2013 02:10:02 GMT) Full text and rfc822 format available.

Forcibly Merged 6394 9507 13301. Request was from Pádraig Brady <P <at> draigBrady.com> to control <at> debbugs.gnu.org. (Mon, 14 Jan 2013 02:10:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 11 Feb 2013 12:24:03 GMT) Full text and rfc822 format available.

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

Previous Next


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