staden-lg/tables/alus/fasta-split
2021-12-04 05:07:58 +00:00

17 lines
342 B
Bash

#! /bin/sh
AWK=gawk
for x in $*
do
echo splitting ${x}
$AWK '
BEGIN { f = ""; }
/^>/ { if ( f != "" ) close(f); f = substr($1,2);
"if [ -r " f " ] ; then echo yes ; else echo no ; fi" | getline result;
if (result == "yes") { print "File " f " already exists"; f = "";} else
print f;
next;}
{if (f != "") print $0 >> f ;}
' $x
done