LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Scripting question concerning random selection of a phrase from a database (https://www.linuxquestions.org/questions/linux-newbie-8/scripting-question-concerning-random-selection-of-a-phrase-from-a-database-602911/)

cjaysson 11-28-2007 12:47 AM

Scripting question concerning random selection of a phrase from a database
 
I am trying to set up a script that randomly selects from a list of phrases such as "I'm meltiiing..." or "All good things must come to an end" every time I shut down.

So far, I have this, roughly (going from memory):
Quote:

ECHO All good things must come to an end
shutdown -h
What I want to do is to have it retrieve something from another file to echo before it shuts down.

I appreciate any help,

cjay

matthewg42 11-28-2007 01:19 AM

Investigate the fortune program, which is designed for this purpose. It also comes with a huge colection of phrases.

indeliblestamp 11-28-2007 02:53 AM

If you want your own customized quotes and not fortune's bundled ones, you can make your own.
Just create a file (e.g. 'myquotes') in /usr/share/fortune/ with formatting and line-separators similar to the ones in existing fortune files
Create a dat file by running strfile myquotes myquotes.dat
Call it from fortune by running fortune myquotes
See this link for details.


All times are GMT -5. The time now is 11:26 PM.