#961638 proposal: stocat - probabilistic cat

Package:
moreutils
Source:
moreutils
Description:
additional Unix utilities
Submitter:
Stefano Zacchiroli
Date:
2021-03-23 21:03:03 UTC
Severity:
wishlist
Tags:
#961638#5
Date:
2020-05-26 21:39:42 UTC
From:
To:
I'm hereby proposing the inclusion of the attached "stocat" utility to
moreutils. It's like cat, but output lines with a given probability, defaulting
to 10%. It's very useful for random sampling (and *much* more efficient at that
than using "shuf" which is unwieldy on very large inputs) and, while it can be
implemented instead with awk/perl oneliners, those oneliners aren't very
mnemonic and are error prone.

If desired, it could be extended by adding a reservoir sampling option, to
guarantee a selection of exactly K items.

Thanks a lot for moreutils!

Cheers

#961638#10
Date:
2021-03-10 13:38:55 UTC
From:
To:
Heya, as I haven't heard back about this, but others have asked me about
how to best use stocat, I've now released it as an independent tool
here:

https://gitlab.com/zacchiro/stocat

I'm happy to reconsider if/when it gets integrated into moreutils.

Cheers

#961638#15
Date:
2021-03-18 21:07:58 UTC
From:
To:
Dear Joey,

Stefano suggested the inclusion of his 'stocat' (see below) tool into
moreutils.  I think the simple script is a great idea and I would like
to see it in the moreutils collection.  What do you think?  Might you
consider to adopt it?

Kind regards,
Nicolas