http://qs321.pair.com?node_id=11121096


in reply to Split tab-separated file into separate files, based on column name

If you want the very bare functionnality a oneliner might work, but you'll need to switch to a longer script for pretty much any kind of control you may want to have over the result:

perl -lanE 'for (0..$#F) { `echo $F[$_] >> file$_` }'
You can read perlrun to understand what the options do (and change the way the file is split, because it's split on whitespace by default, not tabs). It will fail if the input is not simple enough (if there are quotes, dashes, or semi colons in the data). And you'll start to get extra output data if you call it several times in a row.

All that being said, you asked for the clever way. The clever way is to keep the solution that you understand, if you ever have to fix it.

Edit s/perlun/perlrun/. Thanks AnomalousMonk