Bug 239467 - [NEW PORT] sysutils/frand: Selects a random file from given directory.
Summary: [NEW PORT] sysutils/frand: Selects a random file from given directory.
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Rodrigo Osorio
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-07-26 19:34 UTC by serpent7776
Modified: 2019-08-20 21:41 UTC (History)
1 user (show)

See Also:


Attachments
shar archive with port files (1.92 KB, text/plain)
2019-07-26 19:34 UTC, serpent7776
no flags Details
shar archive with updated descriptions (2.14 KB, text/plain)
2019-08-14 19:32 UTC, serpent7776
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description serpent7776 2019-07-26 19:34:49 UTC
Created attachment 206089 [details]
shar archive with port files

This is a small console utility that prints a random file name from given directory to standard output.
Comment 1 Rodrigo Osorio freebsd_committer 2019-07-29 10:23:13 UTC
Hi,

No offense, but what's the benefit of your tool compared to `find . -type f -maxdepth 1 | sort -R | head -n1` command line ?

The reservoir-sampling algorithm provide some benefits here ?

Regards,
-- rodrigo
Comment 2 serpent7776 2019-07-29 20:14:29 UTC
No offense taken. The reservoir-sampling algorithm will provide benefit for big directories, as it doesn't require sorting input data. For most cases find+sort will do just fine though.
I've created this port mainly for myself, so I can easily install this tool on my system. If you don't find this tool useful, I don't mind not including it is ports. I can always fallback to portshaker.
Comment 3 Rodrigo Osorio freebsd_committer 2019-08-08 13:37:45 UTC
At this points just two remarks:

The algorithm used (reservoir-sampling) should be notified
in the package description.

And you should add a few words about the benefits of this
solution in the long description aka pkg-descr.
Comment 4 serpent7776 2019-08-14 19:32:00 UTC
Created attachment 206553 [details]
shar archive with updated descriptions
Comment 5 commit-hook freebsd_committer 2019-08-18 10:34:49 UTC
A commit references this bug:

Author: rodrigo
Date: Sun Aug 18 10:34:08 UTC 2019
New revision: 509198
URL: https://svnweb.freebsd.org/changeset/ports/509198

Log:
  Add new port sysutils/frand

  frand is a command line tool who returns
  a random file from a given directory using
  the reservoir sampling algorithm.

  With reservoir sampling algorithm, directory
  contents doesn't need to be read in memory
  then sorted and so will perform much better
  than find+sort for directories with a large
  amount of files.

  PR:		239467
  Submitted by:	serpent7776@gmail.com

Changes:
  head/sysutils/Makefile
  head/sysutils/frand/
  head/sysutils/frand/Makefile
  head/sysutils/frand/distinfo
  head/sysutils/frand/pkg-descr
  head/sysutils/frand/pkg-plist
Comment 6 Rodrigo Osorio freebsd_committer 2019-08-18 10:35:17 UTC
Committed, thanks.