Consider a database in which each record is a cooking recipe. It is
always difficult to decide what to cook each day, so it would be nice
if we could ask recsel to pick up a random recipe. This can
be achieved using the
--random command line option
$ recsel -m 1 recipes.rec Title: Curry chicken Ingredient: A whole chicken Ingredient: Curry Preparation: ...
In case we need two recipes, because we will be cooking for
both lunch and dinner, we can pass a different number to
$ recsel -m 2 recipes.rec Title: Fabada Asturiana Ingredient: 300 gr of fabes. Ingredient: Chorizo Ingredient: Morcilla Preparation: ... Title: Pasta with ragu Ingredient: 500 gr of Spaghetti. Ingredient: 2 tomatoes. Ingredient: Minced meat. Preparation: ...
Note that the algorithm used to implement
-m guarantees that
you will never get multiple instances of the same record. This means
that if a record set has n records and you ask for n
random records, you will get all the records in a random order.