Valid XHTML 1.0!

litdb

Catranges

You know that you can get a range of lines from the beginning of a file with the utility head, and from the end with tail. Thus, by chaining these tools you can select a range of lines from the middle (or you use sed or awk, which allow you to do this directly). But what if you want to extract a regularly repeated pattern of lines?

Probably there would be a way to do this also directly in awk, but I do not know it. Anyway, I have written a tool catranges to do just that. It allows you to specify an initial range of lines to skip, and then in a loop echoes N lines and skips S lines until the end-of-file. As always, it is written in pure C99, and it is organized as a filter, thus, by chaining with tr, you are not restricted for extracting lines, but can use any separator character you like.

Here is the source code. It is so trivial, thus I allow you to do with it anything you want (i.e., I attach no licence requirements to it).
Phone: +49-89-289-11762 | Email: michael.leitner@frm2.tum.de | last modified: 30.04.2019