Package: moreutils
Version: 0.24
Severity: wishlist

How about a utility to sample every Nth line of stdin to stdout?  This
could be useful for humans monitoring the real-time output of noisy
programs like tshark or as part of a pipeline prior to an expensive
filter.  Something like:

$ cat samp.c
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char **argv){
    if(argc > 1){ 
        int samp = atoi(argv[1]);
        int c = 0;
        char *line = NULL; 
        size_t len = 0;
        while(getline(&line, &len, stdin) != -1){ 
            if(c % samp == 0) fputs(line, stdout);
            ++c;
        }
        if(line) free(line);
        return EXIT_SUCCESS;
    }
    return EXIT_FAILURE;
}
$

-- 
Robert Edmonds
[EMAIL PROTECTED]

Attachment: signature.asc
Description: Digital signature

Reply via email to