I am trying to combine my understanding of dynamic regular expressions with awk's ability to print lines between two patterns in order to obtain lines between two patterns that could be bash variables. In this specific instance, the first pattern is a bash variable, and the other pattern is the following occurrence of a wildcard that begins with ">". The data looks something like:
CGCGCGCGCGCGCGCGCGCGCGCG
>jcf719000004955 0-783586
ACGTACGTACGTACGTACGTACGT
ACGTACGTACGTACGTACGTACGT
ACGTACGTACGTACGTACGTACGT
>jcf_anything 0-999999
TATATATATATATATATATATATA
TATATATATATATATATATATATA
And I would like to obtain just:
ACGTACGTACGTACGTACGTACGT
ACGTACGTACGTACGTACGTACGT
ACGTACGTACGTACGTACGTACGT
So, using these variables:
i="jcf719000004955"
data="/bin/file"
Neither of these matching patterns work:
awk '/^\>$i/{f=1;next} /^\>.*/{f=0} f' $data
awk '/^\>$i/{f=0} f; /^\>.*/{f=1}' $data
I'm able to use dynamic regular expressions to get the matching pattern containing my bash variable as such:
awk -v var="$i" '$0 ~ var ' $data | head -1
>jcf719000004955 0-783586
But how do I combine the use of dynamic regular expressions in order to obtain the lines in between two variables/patterns?