Printing random lines of a file
I've been using the remind program to print reminders for various things, and it's usually pretty straightforward to use, but I've run into something I can't figure out how to do. I'd like to be able to get a reminder that is one randomly picked from a long list, rather that something I've scheduled for that specific day. It looks like remind can call a remote program, so I guess it boils down to needing something that will take a file, pick a given number of random lines from that file, and print them out. Any ideas?
|
I happen to have already written just such a program, which I use to pick random words from a dictionary file. It should be self explanatory and I hope it helps!
Code:
#!/usr/bin/perl |
a related questions is answered in perlfaq5
|
I like the algorithm from the Camel Book.
Any interest in trying to it as a bash script? I think this might work (WARNING -- I have tested the pieces, but not the whole): Code:
#!/bin/bash |
All times are GMT -5. The time now is 03:54 PM. |