The following code is buggy, sorry.
... it will create empty files for each field ...
D:\tmp>type 1,George,CEO 1 George CEO D:\tmp>
strange behavior... (Update: see solution here )
so if you don't mind having the column head included you can go even shorter
D:\tmp>del id,name,position D:\tmp>perl -lanE "open $FH[$x++], '>', $_ for @F;print $_ shift @F f +or @FH" data.txt D:\tmp>type id,name,position id id 1 2 3 name name Nick George Christina position position boss CEO CTO D:\tmp>
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
In reply to Re^2: Split tab-separated file into separate files, based on column name (updated)
by LanX
in thread Split tab-separated file into separate files, based on column name
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |