perl -ane 'print join ("\t",splice(@F, 1 ,1),@F ), "\n"' YourFileNam
+e.txt
Change the middle number in the 'splice' to select an alternative column (minus one, if you think one-relative).
If you wan to parameterize, and make the selected column one-relative, you could do this:
perl -sane 'print join ("\t",splice(@F, $COL-1 ,1),@F ), "\n"' -- -CO
+L=2 YourFileName.txt
Note that you need the "--" to separate 'perl' options from program options.
or - this option that uses fewer keystrokes and space-separated columns:
perl -sape '$_=splice(@F, $COL-1,1)." @F\n"' -- -COL=3 YourFileName.tx
+t
"XML is like violence: if it doesn't solve your problem, use more."
|