Is there a very simple way (maybe using one line with sed?) to get n
lines, starting at ath line within this chunk of n
lines, for every m
lines?
More specifically, I have a file with millions of lines. For every 4 lines, I want to get the first two lines.
But I guess I also want to get an idea of doing this in other similar situations. That's why I asked a more general question here.
Best Answer
With
gnu split
:and if you wanted to do it only after the
i
th line, just redirect the previous lines to/dev/null
:If you don't have access to
gnu
tools you could useawk
: