Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
cat hg18.fa | awk '{
if (substr($0, 1, 1)==">") {filename=(substr($0,2) ".fa")}
print $0 > filename
Copy link

Joytee commented Jul 19, 2021

thanks, it worked

Copy link

Amazing. Worked the first time. Not bad for an 11 year old script. Thanks!

Copy link

wudustan commented Nov 4, 2021

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

Fix originally provided here:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment