Change the middle number in the 'splice' to select an alternative column (minus one, if you think one-relative).perl -ane 'print join ("\t",splice(@F, 1 ,1),@F ), "\n"' YourFileNam +e.txt
If you wan to parameterize, and make the selected column one-relative, you could do this:
Note that you need the "--" to separate 'perl' options from program options.perl -sane 'print join ("\t",splice(@F, $COL-1 ,1),@F ), "\n"' -- -CO +L=2 YourFileName.txt
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."
In reply to Re: Reorganizing Columns with Perl One Liner
by NetWallah
in thread Reorganizing Columns with Perl One Liner
by neversaint
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |