Hi all, I need help to split a tab-delimited list into separate files by the filename-field. The list is already sorted ascendingly by filename, an example list would look like this;
filename001 word1 word2
filename001 word3 word4
filename002 word1 word2
filename002 word3 word4
filename002 word5 word6
I have tried this using a slightly modified bash script which I found here on unix.com :
awk -F"\t" 'OFS="\t"{print >> ($1 ".tab")}' tabdelimitedfile.tab
This outputs the files filename001.tab and filename002.tab
Unfortuneatly this will not work on larger files than the example listed above if too many different file names are found. I get the error message "awk: *.tab makes too many open files" on exit.
I would be grateful if anyone could suggest an alternative way which outputs one file at a time every time a new filename is encountered.
Cheers
Per