Thank you for the code :), here is the error I get.
awk -F '[ :]' '{f = $3 ".txt"; close($3 ".txt")} print > "/home/cmccabe/Desktop/panels/BMF/" f}' BMF_unix_loop_genes_IonXpress_008_150902_loop_genes_average_IonXpress_008_150902.bed
awk: line 1: syntax error at or near print
awk: line 1: extra '}'
If I remove the close($3 ".txt")} it works great. Thank you :).
Not really... There are a couple of problems here.
The standards don't define the precedence between output redirection and string concatenation in awk print commands. So, although it appears to work on your system, it isn't portable. And, if you write to one string, as in:
print > ("/home/cmccabe/Desktop/panels/BMF/" f)
you need to close that same string; so:
close(f)
is a no-op because f has never been opened. So, what you really need is something more like: