While your code looks ok, it could be improved greatly by making use of RS
(record separator) and NR
number of record, provided you're using GNU awk
.
awk -v RS='```[a-z]*\n' '(NR+1)%2' file
In this case RS
is set such that it is composed ofcatching everything between triple backticks (and possible somewith optional text).
The only awk
statement is to print one record out of two.