Re: cut - reorder fields (original) (raw)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
From: | Bob Proulx |
---|---|
Subject: | Re: cut - reorder fields |
Date: | Thu, 27 Sep 2007 16:29:00 -0600 |
User-agent: | Mutt/1.5.9i |
James KEEFER wrote:
As far as I can see, there is no way to re-order fields using cut.
That is correct. But other tools do this easily.
It would be nice to be able to specify -f 3,2,1 and have the first three fields switched in their order. It would also be nice to repeat an input fields in the output, such as -f 1,1,1 repeating the first field three times.
I suggest using awk for this. It is a standard tool that will do exactly what you are asking.
$ echo one two three four | awk '{print 3,3,3,1,$2}' three one two
$ echo one two three four | awk '{print 3,3,3,2,$1,$2}' three two one two
Using awk just seems perfectly fitted to these types of tasks.
Bob
- cut - reorder fields, James KEEFER, 2007/09/27
- Re: cut - reorder fields,Bob Proulx <=
- Prev by Date:cut - reorder fields
- Next by Date:Possible bug in sort 5.97
- Previous by thread:cut - reorder fields
- Next by thread:Possible bug in sort 5.97
- Index(es):