Re: How to exchange two columns in a table?

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

 



On Sat, Jan 06, 2007 at 11:14:40AM +0800, coscell@xxxxxxxxxxxxxx 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.

_______________________________________________
Blinux-list mailing list
Blinux-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/blinux-list

[Index of Archives]     [Linux Speakup]     [Fedora]     [Linux Kernel]     [Yosemite News]     [Big List of Linux Books]