Skip to main content
added 33 characters in body
Source Link
oliv
  • 231
  • 1
  • 5

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.

While your code looks ok, it could be improved greatly by making use of RS (record separator) and NR number of record.

 awk -v RS='```[a-z]*\n' '(NR+1)%2' file

In this case RS is set such that it is composed of everything between triple backticks (and possible some text).

The only awk statement is to print one record out of two.

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 catching everything between triple backticks with optional text.

The only awk statement is to print one record out of two.

Source Link
oliv
  • 231
  • 1
  • 5

While your code looks ok, it could be improved greatly by making use of RS (record separator) and NR number of record.

 awk -v RS='```[a-z]*\n' '(NR+1)%2' file

In this case RS is set such that it is composed of everything between triple backticks (and possible some text).

The only awk statement is to print one record out of two.