in bash, linux, technology

Making New Fortunes (in linux)

technology.pngAnother week, another bash script!

One of the things I love about scripting things like this is getting to know what’s really going on inside my computer. I’m that way about most things – sure, it’s nice to have things “just do”, but I also want to know why they’re just doing. Maybe I’ll never use that information, maybe I’ll need it tomorrow.

These scripts are usually for things that I needed that other people didn’t provide. For example, the fortune command in *nix.

Fortune’s pretty cool – it randomly pops up a quotation whenever you log in or invoke it. You can pipe the output through cows and get output like this:

 _______________________________________
/ Have a place for everything and keep  
| the thing somewhere else; this is not |
| advice, it is merely custom.          |
|                                       |
 -- Mark Twain                         /
 ---------------------------------------  
  
      
         /
        ( )
      .( o ).
 ___________________________________
/ We own our government and are not 
 merely its consumers.             /
 -----------------------------------
     
      
          oO)-.                       .-(Oo
         /__  _                     /_  __
           (  |     ()~()         |  )/  /
          __| |    (-___-)        | /|__/
          '  '--'    ==`-'==        '--'  '
 _____________________________________
/ Writing is easy; all you do is sit  
| staring at the blank sheet of paper |
| until drops of blood form on your   |
| forehead.                           |
|                                     |
 -- Gene Fowler                      /
 -------------------------------------
          ,__,
          (oo)____
           (__)    )
              ||--|| *

I see cool-ass quotations everyday; there’s lots of quotation tweeters out there. Many of them I’d like to add to my fortune files. Adding the text isn’t hard – you just put a % between each line in the file and put the file in /usr/share/games/fortunes. Mine are in /usr/share/games/fortunes/bigquotes , for example. But it’s got to run a database command to create this other file and… well, I wanted to automate it. I’m lazy.

The bash script below adds a ONE LINE QUOTATION to the file bigquotes and compiles it for use with the fortune program.

You can download the code to examine or run directly here

Write a Comment

Comment