This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cat hg18.fa | awk '{ | |
if (substr($0, 1, 1)==">") {filename=(substr($0,2) ".fa")} | |
print $0 > filename | |
}' |
Amazing. Worked the first time. Not bad for an 11 year old script. Thanks!
I was running into the 'Too many open files' error.
Here is a fix:
cat hg18.fasta | awk '{
if (substr($0, 1, 1)==">") {filename=(substr($0,2) ".fasta")}
print $0 >> filename
close(filename)
}'
Fix originally provided here: https://unix.stackexchange.com/questions/498001/splitting-file-by-1st-column-too-many-open-files
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks, it worked