sed with next line (`+N` option) and frequency (`~N`) together

Use the ADDR1,ADDR2 with FIRST~STEP as ADDR1 and +OFFSET as ADDR2, so:

$ seq 30 | sed '10~10,+1!d'
10
11
20
21
30

In anycase, note that both ~ and + are non-standard GNU extensions.

See info sed 'line selection' and info sed 'range of lines' on a GNU system for details.

POSIXly, you'd use:

seq 30 | sed -n '1n;n;n;n;n;n;n;n;n;p;n;p'

How about an awk solution?

awk '(FNR>1) && (FNR%10<2)' file
  • FNR is awks automatically updated per-file line-counter
  • Any condition outside of a "rule block" ({ ... }) that evaluates to "true" (and be it the string 1) will instruct awk to print the current line, including all modifications made so far.
  • So, (FNR>1) && (FNR%10<2) will print the current line, if it is not the first line, and if the line number is an integer multiple of 10 (or +1 from such a multiple at most). This is equivalent to "every 10th and line and the following".

Using awk we can do as shewn. NR is line number in awk parlance.

$ awk 'NR ~ /.[10]$/'  file

With sed we could do as shown below where we increment the hold space till we hit the 10 count of newlines.

$ sed -nE 'x
  /\n{9}/{
    z;x;$d
    N;p;D
  }
  s/$/\n/;h
' file
$ perl -ne '$.%10||print($_.<>)' file