[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: How to exchange two columns in a table?



On Sat, Jan 06, 2007 at 11:14:40AM +0800, coscell mail batol net wrote:
> Thank you! It's just a tab-delimited text file.

Other than the several programming-based approaches suggest so far,
I'll throw in a more simplistic method.  Since the columns are
clearly delineated (and, in this case, by a tab character, which
works perfectly as the default delimiter here), you can just use
"cut" and "paste":

   cut -f1 inputfile > col1
   cut -f2 inputfile > col2
   paste col2 col1 > outputfile

It's easy to generalize this to any number of columns, and any given
column arrangement.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]