I have a file with the following:
>NODE_1_length_281510_cov_20.148788
CGTCGAGACAACCAAGAAGCACGGCAACTCGCCCTACAACGCAATCCTCGCCCTTCTCTA
I want to sub in a variable between the > and NODE to get
>variable_NODE_1_length_281510_cov_20.148788
CGTCGAGACAACCAAGAAGCACGGCAACTCGCCCTACAACGCAATCCTCGCCCTTCTCTA
Is it possible to do something like the following with gsub in awk? $foo is the variable.
awk -v a="$foo" '{if(!/>NODE/){print; next}; gsub("NODE",a,$1);print}' "$file">> "${foo}.fasta"
I'm not getting any error. The script is just getting stuck. I know my solution will only replace the word NODE with the directory name. Is it possible to do concatenation inside gsub?